What Is the Difference Between 'End' and 'End As'

Simple question. I noticed it seems I can use them interchangeably, but I wasn't sure if they were the exact same command. I searched online and couldn't find anything? Here an example query that gives me the same result:

select 
case when ID in ('1', '2', '3')
then 'Jack'
else 'Jim'
end as Person
from Table.Names

select
case when ID in ('1', '2', '3')
then 'Jack'
else 'Jim'
end Person
from Table.Names

2 Answers

The as in the statement is aesthetic. It tells the compiler that you are setting a name.

1

END is the marker that closes the CASE expression. You must have exactly one END statement for every CASE Statement. The AS marker is used to introduce an alias.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

James H. Sterling

James H. Sterling

Environmental Science & Climate Journalist

James Sterling reports on renewable energy developments, climate policy, ecological conservation, and green tech innovations around the globe.

Share this article
Twitter Facebook Pinterest