Subject | Re: please help me with this query, TNX!!! |
---|---|
Author | fabiano_bonin |
Post date | 2003-06-08T22:07:58Z |
Hi, Roberto.
You can do that in a single statement just with the great FB 1.5.
In FB 1.0 you will probably need a SP.
create table test1 (
column1 integer,
column2 integer,
column3 integer );
-> Insert some records
select
( ( case when x.column1 = :column1 then 1 else 0 end ) +
( case when x.column2 = :column2 then 1 else 0 end ) +
( case when x.column3 = :column3 then 1 else 0 end )
) as column1,
x.*
from
test1 x
where
( x.column1 = :column1 ) or
( x.column2 = :column2 ) or
( x.column3 = :column3 )
order by
1 desc
-> And you have your big matching ordered first
--- In ib-support@yahoogroups.com, "Roberto Della Pasqua"
<roberto@d...> wrote:
You can do that in a single statement just with the great FB 1.5.
In FB 1.0 you will probably need a SP.
create table test1 (
column1 integer,
column2 integer,
column3 integer );
-> Insert some records
select
( ( case when x.column1 = :column1 then 1 else 0 end ) +
( case when x.column2 = :column2 then 1 else 0 end ) +
( case when x.column3 = :column3 then 1 else 0 end )
) as column1,
x.*
from
test1 x
where
( x.column1 = :column1 ) or
( x.column2 = :column2 ) or
( x.column3 = :column3 )
order by
1 desc
-> And you have your big matching ordered first
--- In ib-support@yahoogroups.com, "Roberto Della Pasqua"
<roberto@d...> wrote:
> hello kind users,can help me? I need to achieve this, imagine:
>
> really I lack of a strong SQL knowledge, so please can somebody
>field3=X
> select first 10 from maintable where field1=X OR field2=X OR
>big matching,
> I like to have the select list ordered by the records that have
> so as example the first record will be the record that has bothfield1,field2 and field3 mathching,
> the second record will be a record with only two field matching...and so one.
>
> Please forgive my bad english.
>
> Kind regards and really thanks,
>
> Roberto.
>
> [Non-text portions of this message have been removed]