Thursday, 11 April 2013

how select first id equal to zero then desding order

SELECT        id, name, city, ImageName, ImagePath
FROM            aaaa
ORDER BY CASE WHEN ID > 0 THEN
                             (SELECT        MAX(ID)
                               FROM            [dbo].[aaaa]) + 1 ELSE 0 END, id DESC


No comments:

Post a Comment