|
Posted by Plamen Ratchev on 05/15/07 12:54
Please don't multipost, rather crosspost. Replied in
microsoft.public.sqlserver.server:
SELECT F.ID,
F.LASTNAME
FROM Foobar AS F
LEFT OUTER JOIN
(
SELECT ID,
MIN(LASTNAME) AS GRP
FROM Foobar
WHERE ID > 0
GROUP BY ID
) AS G
ON F.ID = G.ID
ORDER BY COALESCE(G.GRP, F.LASTNAME),
F.ID,
F.LASTNAME
HTH,
Plamen Ratchev
http://www.SQLStudio.com
[Back to original message]
|