[thelist] SQL Help needed
rudy
r937 at interlog.com
Thu Jan 31 20:46:00 CST 2002
> ... This sorts the results by "paiduntil" and then "lastloggedon".
> While this is fine for the results that have "paiduntil" as NULL, it
> orders "paiduntil" which are not NULL by "paiduntil" and then
> "lastloggedon", whereas I want to order the results by "lastloggedon"
> but have the records which have a datestamp in the field "paiduntil"
> displayed first.
oh, okay, then you'll want
SELECT 0, * FROM TableA WHERE paiduntil IS NOT NULL
UNION ALL
SELECT 1, * FROM TableA WHERE paiduntil IS NULL
ORDER BY
1, lastloggedon
i.e. don't sort on paiduntil, just lastloggedon
rudy
More information about the thelist
mailing list