Link to home
Start Free TrialLog in
Avatar of Camillia
CamilliaFlag for United States of America

asked on

Order by but want it in specific order

This is SQL 2014

I have this SQL statement but users want the rows to be displayed in specific order

SELECT        orm.OrderRemarkId, rs.RemarksSectionId, orm.Remark, CASE rs.Name WHEN 'Order Terms' THEN 'Terms : ' WHEN 'Price' THEN 'Price : ' ELSE '' END AS Name
FROM            RemarksSections AS rs LEFT OUTER JOIN
                         OrderRemarks AS orm ON orm.Section_RemarksSectionId = rs.RemarksSectionId LEFT OUTER JOIN
                         CommSalesOrders AS c ON c.CommSalesOrderId = orm.CommSalesOrder_CommSalesOrderId
WHERE        (c.ConfirmationNumber = 'wie200-001') AND (rs.Name NOT IN ('Header', 'Any Section', 'Order Detail','Order Message'))

Open in new window


This is the output

User generated image
I need to order the output in a specific order of "RemarkSectionId"
8
3
7
9
1
2

How can I do that? with a case statement?
ASKER CERTIFIED SOLUTION
Avatar of Jim Horn
Jim Horn
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Camillia

ASKER

thanks, let me see