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

Order By to appear second last

Status
Not open for further replies.

gus121

Technical User
May 9, 2002
298
GB
How do I select an item to appear as the 2nd last most ordered item on a list is this possible.
This is the SQL which retrieves the data that i wish i just wish to alter the ORDER BY statment so instead of displaying at the top it apperars 2nd from last.
I will loop through this query creating some HTML table structure based on the result.


CREATE PROCEDURE [dbo].[usp_CategoryTabs]
@SectionID int,
@Sitemask int

AS
SELECT
SectionID,
SectionName
FROM
tblSections


WHERE
(SiteMask & @Sitemask > 0) AND (Tab = 1)

ORDER BY CASE WHEN SectionID = @SectionID THEN 0 ELSE 1 END

thanks for your time

Angus



-Gus
 
I'm not sure I understand your question. Could you post a sample of your data (section id/name) and the order you want them returned?

--James
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top