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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sort Feild by 3 criteria 1

Status
Not open for further replies.

alexanderthegreat

IS-IT--Management
Sep 9, 2005
70
0
0
US
I want the order by for scrollercategories.id to be 2,3,1

How would I accomplish this?

SELECT TOP 200 dbo.scroller.id, dbo.scroller.srolltitle, dbo.scroller.scrolllink, dbo.scroller.scrollsource, dbo.scroller.eventdate, dbo.scroller.active,dbo.scrollercategories.scrollcategory, dbo.scrollercategories.id AS cid
FROM dbo.scroller INNER JOIN
dbo.scrollercategories ON dbo.scroller.sid = dbo.scrollercategories.id
ORDER BY dbo.scroller.active, dbo.scrollercategories.id, dbo.scroller.eventdate DESC

Thanks
 
Code:
SELECT TOP 200
       dbo.scroller.id, dbo.scroller.srolltitle,
       dbo.scroller.scrolllink, dbo.scroller.scrollsource,
       dbo.scroller.eventdate,dbo.scroller.active,
       dbo.scrollercategories.scrollcategory,
       dbo.scrollercategories.id AS cid,
       CASE dbo.scroller.sid WHEN 2 THEN 1
                             WHEN 3 THEN 2
                             WHEN 1 THEN 3
       ELSE dbo.scroller.sid END AS OrderBy
FROM dbo.scroller
INNER JOIN dbo.scrollercategories 
          ON dbo.scroller.sid = dbo.scrollercategories.id
ORDER BY dbo.scroller.active,
         OrderBy,
         dbo.scroller.eventdate DESC

Borislav Borissov
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top