Subject | SQL ORDER BY problem |
---|---|
Author | mircostange |
Post date | 2002-07-25T09:19:20Z |
Hi Everyone,
I am having a problem to find an appropriate SQL select statement for
the following scenario.
I have a table (say A) with columns (say c1, c2, etc). What I need
now is a select statement that returns
all rows with c1=x and c2=y
OR
if no such row exists any c1=x
This doesnt seem to be possible, so I am trying to figure out whether
I can select all rows with c1=x, but
* ordered so that rows with c2=y appear on the top *
It seems that
SELECT * from A where c1=x ordered by c2=y
does not work.
Any alternatives?
Mirco
I am having a problem to find an appropriate SQL select statement for
the following scenario.
I have a table (say A) with columns (say c1, c2, etc). What I need
now is a select statement that returns
all rows with c1=x and c2=y
OR
if no such row exists any c1=x
This doesnt seem to be possible, so I am trying to figure out whether
I can select all rows with c1=x, but
* ordered so that rows with c2=y appear on the top *
It seems that
SELECT * from A where c1=x ordered by c2=y
does not work.
Any alternatives?
Mirco