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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Select statment with 5 roles and 2 branches

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...me



Regards,
Krishna Murthy.K



Mamatha

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?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

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...me



Table structure is like this ...



EMPid Ename Designation BranchName
NGH32001 Rambabu CEO B'lore
NGH32002 krishna Murthy PRG Hyderabad
NGH32003 Jyothi PL Hyderabad
NGH32004 Srinivas BM Hyderabad
NGH32005 mummy PL Hyderabad
NGH32006 Sandya PRG Hyderabad
NGH32007 Balu PRG Visakhapatnam
NGH32008 Sravani PRG Visakhapatnam
NGH32009 gurunath BM Visakhapatnam
NGH32010 gaffar PL Visakhapatnam
NGH32011 Koti PL Visakhapatnam


I need the output like
first 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
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-08-19 : 06:51:40
Try this although it is not efficient
You can write query something like this

Select columns from yourTable
order by case when Designation like '%CEO' then 1 when Designation like '%BM' then 2
when Designation like '%PL' then 3 when Designation like '%PRG' then 4 end




Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -