Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need a Column Name defined in statement 3

Status
Not open for further replies.
Mar 17, 2005
147
US
How can I give a name to the column where this statement displays its results?

SELECT *,
case srctable_cah
when 'dbo.activity' then 'Activities at 689'
when 'dbo.goal' then 'Goals'
when 'dbo.technician' then 'Technicians Report'
when 'dbo.marketintell' then 'Market Intelligence'
when 'dbo.activityout' then 'Activities Outside 689'
when 'dbo.targetartist' then 'Target Artist Update'
else '...'
end
FROM admin.src_cache_cah
 
SELECT
column= case srctable_cah
when 'dbo.activity' then 'Activities at 689'
when 'dbo.goal' then 'Goals'
when 'dbo.technician' then 'Technicians Report'
when 'dbo.marketintell' then 'Market Intelligence'
when 'dbo.activityout' then 'Activities Outside 689'
when 'dbo.targetartist' then 'Target Artist Update'
else '...'
end
FROM admin.src_cache_cah

Dr. Sql
goEdeveloper@yahoo.com
Good Luck.
 
Try THis

Code:
SELECT *,
[COLOR=red]MYCOLUMN = [/color]case srctable_cah
       when 'dbo.activity' then  'Activities at 689'
       when 'dbo.goal' then 'Goals'
       when 'dbo.technician' then 'Technicians Report'
       when 'dbo.marketintell' then 'Market Intelligence'
       when 'dbo.activityout' then 'Activities Outside 689'
       when 'dbo.targetartist' then 'Target Artist Update'
       else '...'
       end
FROM admin.src_cache_cah

Shoot Me! Shoot Me NOW!!!
- Daffy Duck
 
Just to show you another way to do the same:
Code:
SELECT *,
       case srctable_cah
       when 'dbo.activity' then  'Activities at 689'
       when 'dbo.goal' then 'Goals'
       when 'dbo.technician' then 'Technicians Report'
       when 'dbo.marketintell' then 'Market Intelligence'
       when 'dbo.activityout' then 'Activities Outside 689'
       when 'dbo.targetartist' then 'Target Artist Update'
       else '...'
       end [COLOR=red] 'MYCOLUMN' -- you can get rid of the quotes too [/color]
FROM admin.src_cache_cah

Regards,
AA
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top