Solved

how do I sort this criteria in sql server?

Posted on 2008-06-10
2
562 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
[X]
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
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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
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.
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.

729 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