Solved

how do I sort this criteria in sql server?

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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SSRS 2013 - Creating a summarized report 19 36
sql server computed columns 11 31
Tsql query 6 22
sql server service accounts 4 27
Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
I have a large data set and a SSIS package. How can I load this file in multi threading?
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Viewers will learn how the fundamental information of how to create a table.

809 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