Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
chauhan.shaili
Starting Member
1 Post |
Posted - 2013-02-21 : 10:01:38
|
Hi, I have following query (there are 3 rows with emp id= 1234, and 2 with 5678)Select EMP_ID from EMPLOYEE where EMP_ID = '1234' OR EMP_ID = '5678' Out putEMP_ID------12341234123456785678In above query is it possible to select a static/constant colum with a flag so that it flags likeEMP_ID MY_FLAG------ -------1234 A 1234 A1234 A5678 B5678 B |
|
obedrodriguez
Starting Member
9 Posts |
Posted - 2013-02-21 : 10:12:53
|
Select EMP_ID, CASE EMP_ID WHEN '1234' then 'A' WHEN '5678' then 'B' END AS 'MY_FLAG'FROM EMPLOYEE where EMP_ID = '1234' OR EMP_ID = '5678' |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-02-21 : 22:27:27
|
are you looking at generating flags automatically for each emp_ID. then solution should be like below:-SELECT EMP_ID,CHAR(64 + DENSE_RANK() OVER (ORDER BY EMP_ID))FROM table question is how do you want values to come if there are more than 26 distinct ids so that alphabets are finished!------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
|
|
|