Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
DB Engine
SQL ServerMSDESQL Server CE
Services
Analysis (Data Mining)Analysis (OLAP)DTSIntegration ServicesNotification ServicesReporting Services
Programming
CLRConnectivitySQLXML
Other Technologies
ClusteringEnglish QueryFull-Text SearchReplicationService Broker
General
Data WarehousingPerformanceSecuritySetupSQL Server ToolsOther SQL Server Topics
DirectoryUser Groups
Related Topics
MS AccessOther DB ProductsMS Server Products.NET DevelopmentVB DevelopmentJava DevelopmentMore Topics ...

SQL Server Forum / General / Other SQL Server Topics / August 2005

Tip: Looking for answers? Try searching our database.

How to write query

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Yoshitha - 19 Aug 2005 08:29 GMT
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
Cristian Lefter - 19 Aug 2005 10:16 GMT
Hi Yoshitha, HTH
[code]
SELECT 1 as CustomGroup,empname,designation,branch
FROM MyTable
WHERE designation = 'CEO' and branch='Hyderabad'
UNION ALL
SELECT 2 as CustomGroup,empname,designation,branch
FROM MyTable
WHERE designation = 'BM' and branch='Hyderabad'
SELECT 3 as CustomGroup,empname,designation,branch
FROM MyTable
WHERE designation = 'PL' and branch='Hyderabad'
SELECT 4 as CustomGroup,empname,designation,branch
FROM MyTable
WHERE designation = 'Tester' and branch='Hyderabad'
SELECT 5 as CustomGroup,empname,designation,branch
FROM MyTable
WHERE designation = 'PRG' and branch='Hyderabad'
UNION ALL
SELECT 6 as CustomGroup,empname,designation,branch
FROM MyTable
WHERE designation = 'CEO' and branch='Visakhapatnam'
UNION ALL
SELECT 7 as CustomGroup,empname,designation,branch
FROM MyTable
WHERE designation = 'BM' and branch='Visakhapatnam'
SELECT 8 as CustomGroup,empname,designation,branch
FROM MyTable
WHERE designation = 'PL' and branch='Visakhapatnam'
SELECT 9 as CustomGroup,empname,designation,branch
FROM MyTable
WHERE designation = 'Tester' and branch='Visakhapatnam'
SELECT 10 as CustomGroup,empname,designation,branch
FROM MyTable
WHERE designation = 'PRG' and branch='Visakhapatnam'
ORDER BY CustomGroup
[/code]

Cristian Lefter, SQL Server MVP

>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
[quoted text clipped - 10 lines]
> Regards,
> Krishna Murthy.K
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.