Solved

how do I sort this criteria in sql server?

Posted on 2008-06-10
2
514 Views
Last Modified: 2008-06-10
i want to order by name as well as status in my order the status = A , T, C .. since the status is oder by it gives me the results as A, C, T ... my sql is,
SELECT A.EE_NAME,A.EE_STATUS

		 FROM EMPLOYEE_PERSONAL  A

		 INNER JOIN COMPANY_LIST B ON  A.BROKERID = B.BROKERID AND A.CLIENTID = B.CLIENTID

		 WHERE  A.BROKERID =1 AND B.BROKERID = 1 AND A.CLIENTID = 1

		 AND B.CLIENTID = 2

		 ORDER BY A.EE_STATUS, A.EE_NAME;

Open in new window

0
Comment
Question by:Loganathan Natarajan
2 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 21750019
change
ORDER BY A.EE_STATUS

into

ORDER BY CASE A.EE_STATUS WHEN 'A' THEN 1 WHEN 'T' THEN 2 WHEN 'C' THEN 3 ELSE 99 END
0
 
LVL 36

Author Comment

by:Loganathan Natarajan
ID: 21750059
perfect .. it works... many thanks ..,
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

I wrote this interesting script that really help me find jobs or procedures when working in a huge environment. I could I have written it as a Procedure but then I would have to have it on each machine or have a link to a server-related search that …
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now