Click here to Skip to main content
15,922,309 members
Please Sign up or sign in to vote.
2.78/5 (3 votes)
See more:
SQL
select * from  dbo.UW_VECHICLE_MAP where IE_VECHICLE_CODE=1250


and the output is
IE_VECHICLE_CODE UW_VEHICLE_CODE VEHICLE_MAKE_CODE VEHICLE_MODEL_CODE VEHICLE_SUBTYPE_CODE UW_CODE
1250	38162413	110	7	        72	6
1250	0	        84	12769	        0	11
1250	0	        3803	MARUTI SUZUKI	0	9


now i want uw_code =6 is want add a column and place 'bajaj' for uw_code =6

similarly uw_code =9 is want add a column and place 'tata' for uw_code =9

and so on how to do this


Thanks in adv

Regards,

Rahul
Posted
Updated 10-Sep-13 23:04pm
v3

I think this will fulfill your requirement.

SQL
select *,case when uw_code =6 Then 'bajaj' when uw_code =9 then 'tata' End  as NewColumn from  dbo.UW_VECHICLE_MAP where IE_VECHICLE_CODE=1250
 
Share this answer
 
v2
Try this code.

SQL
select IE_VECHICLE_CODE,UW_VEHICLE_CODE,VEHICLE_MAKE_CODE,VEHICLE_MODEL_CODEVEHICLE_SUBTYPE_CODE,
case
when UW_CODE = 6 then 'bajaj'
when UW_CODE = 9 then 'tata'
end as Company
from dbo.UW_VECHICLE_MAP where IE_VECHICLE_CODE=1250
 
Share this answer
 
v3
Comments
naveen pallela 11-Sep-13 5:35am    
how to give the alias name for the above code its working fine thnk u
ArunRajendra 11-Sep-13 6:48am    
See the modified query.

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