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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding column aliases 1

Status
Not open for further replies.

ecannizzo

Programmer
Sep 19, 2000
213
US
Consider this query:

Code:
select
case when NumLetters <>'0' and SpanishLetter = 'Yes' and Office ='NA' then NumLetters else '0' end "Nash Spanish Letters",  
case when NumLetters <>'0' and SpanishLetter <> 'Yes' and Office ='NA' then NumLetters else '0' end "Nash English Letters"
--"Nash Spanish Letters" + "Nash English Letters" "Total Letters"
from mytable

I want to be able to do the commented row, but it tells me it can't find "Nash Spanish Letters". Is there a way to do this?

Thanks!
 
SELECT nash_spanish_letters + nash_english_letters total_letters
FROM (
SELECT CASE WHEN NumLetters <>'0' AND SpanishLetter = 'Yes' AND Office ='NA' THEN NumLetters
ELSE '0'
END Nash_Spanish_Letters,
CASE WHEN NumLetters <>'0' AND SpanishLetter <> 'Yes' AND Office ='NA' then NumLetters
ELSE '0'
END Nash_English_Letters
FROM mytable
)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top