Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Order by active where active is 1first then where active is 0 1

Status
Not open for further replies.

alexanderthegreat

IS-IT--Management
Sep 9, 2005
70
US
I want to sort the result of this view, so that it sorts by eventdate first descending and where active = 1 then where active = 0 to follow

SELECT TOP 20 dbo.homepage.id, dbo.homepage.title, dbo.homepage.shortdescription, dbo.homepage.active, dbo.homepage.eventdate, dbo.homepage.image,
dbo.homepage.imagecaption, dbo.homecategories.id AS cid, dbo.homecategories.homecategories
FROM dbo.homecategories INNER JOIN
dbo.homepage ON dbo.homecategories.id = dbo.homepage.cid
WHERE (dbo.homecategories.id = 1)
ORDER BY dbo.homepage.eventdate DESC
 
Bonus question: how to sort desc where active=1 then asc where active=0?

------
[small]select stuff(stuff(replicate('<P> <B> ', 14), 109, 0, '<.'), 112, 0, '/')[/small]
[banghead]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top