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 |
|
Mamatha
Posting Yak Master
102 Posts |
Posted - 2005-08-19 : 03:29:36
|
| Hi,I have a table with the fileds empid,empname,designation,branch.. etc I have 5 types of designations CEO,BM,PL,Tester,and PRG and the two branches those are Hyderabad and Visakhapatnam i need the query like first CEO name next Hyderabad BM Name next Hyderabad PL name next Hyderabad Testername next Hyderabad Prg Names next Visakhapatnam BM name next visakhapatnam PL name next Visakhapatnam TesterNames and Visakhapatnam Prg Names......Please help...meRegards,Krishna Murthy.KMamatha |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-08-19 : 04:04:46
|
| Can you post table structures, sample data and the result you want?MadhivananFailing to plan is Planning to fail |
 |
|
|
Mamatha
Posting Yak Master
102 Posts |
Posted - 2005-08-19 : 06:24:27
|
quote: Originally posted by Mamatha Hi,I have a table with the fileds empid,empname,designation,branch.. etc I have 5 types of designations CEO,BM,PL,Tester,and PRG and the two branches those are Hyderabad and Visakhapatnam i need the query like first CEO name next Hyderabad BM Name next Hyderabad PL name next Hyderabad Testername next Hyderabad Prg Names next Visakhapatnam BM name next visakhapatnam PL name next Visakhapatnam TesterNames and Visakhapatnam Prg Names......Please help...meTable structure is like this ...EMPid Ename Designation BranchNameNGH32001 Rambabu CEO B'loreNGH32002 krishna Murthy PRG HyderabadNGH32003 Jyothi PL HyderabadNGH32004 Srinivas BM HyderabadNGH32005 mummy PL HyderabadNGH32006 Sandya PRG HyderabadNGH32007 Balu PRG VisakhapatnamNGH32008 Sravani PRG VisakhapatnamNGH32009 gurunath BM VisakhapatnamNGH32010 gaffar PL VisakhapatnamNGH32011 Koti PL VisakhapatnamI need the output likefirst CEO name next Hyderabad BM Name next Hyderabad PL name next Hyderabad Prg Names next Visakhapatnam BM name next visakhapatnam PL name and Visakhapatnam Prg Names......Please help...me[/font=Verdana]Mamatha
Mamatha |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-08-19 : 06:51:40
|
| Try this although it is not efficientYou can write query something like thisSelect columns from yourTableorder by case when Designation like '%CEO' then 1 when Designation like '%BM' then 2when Designation like '%PL' then 3 when Designation like '%PRG' then 4 endMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|
|