Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

how do I sort this criteria in sql server?

Posted on 2008-06-10
2
545 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 143

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.

840 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