Click here to Skip to main content
15,914,111 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am having a column say TypeOfManager where there will be entries like

TypeOfManager
-----------------
Sales
Relation
S
R
In this case i want to treat 'R' as Relation and 'S' as Sales. What will be the syntax of the query in sql server.
Posted
Comments
Pandya Anil 15-Nov-11 1:46am    
what is the exact output you want, you want to join it with another table ?... place some format
Ston Cold 15-Nov-11 1:49am    
Output Expected
-------------------------------


Sales Relation
------------ ----------
2 2

Just make them the same :
SQL
update tablename set TypeOfManager = 'Relation' where TypeOfManager='R' 
GO 
update tablename set TypeOfManager = 'Sales' where TypeOfManager='S' 
GO
 
Share this answer
 
Comments
RaviRanjanKr 15-Nov-11 8:22am    
5+
Mehdi Gholam 15-Nov-11 8:59am    
Thanks
try with query

select TypeOfManager ,count(TypeOfManager) as count from Tablename group by TypeOfManager 




Regards,
Pal
 
Share this answer
 
Comments
RaviRanjanKr 15-Nov-11 8:23am    
5+
select SUM(Sal) AS 'Sales'
, SUM(Rel) AS 'Relation'
from (
select
CASE WHEN TypeOfManager like 'Sales' THEN 1
WHEN TypeOfManager like 'S' THEN 1
ELSE 0
END AS Sal
, CASE WHEN TypeOfManager like 'Relation' THEN 1
WHEN TypeOfManager like 'R' THEN 1
ELSE 0
END AS Rel
from Tablename
)g
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900