I have to create a constant column with the alias 'Region' in each query. Also, the first query must be labeled the 'Midwest Region' and the second 'Pacific Northwest Region'. I am confused on how I am supposed to alias each one while also setting a constant? I tried inputting "as" in multiple areas but I have just been getting syntax errors. I am new to SQL.
select *
from dealerships
where state in ('IL','IN', 'WI', 'MI')
select *
from dealerships d
where state in ('WA', 'OR', 'ID')
CodePudding user response:
You wrote
SELECT *
...
SELECT *
For "constant" column values you want
SELECT *, 'Midwest Region' AS region
...
SELECT *, 'Pacific Northwest Region' AS region
As far as the UNION thing goes, there's more than one place on the internet where you could RTFM, including: https://en.wikipedia.org/wiki/Set_operations_(SQL)#UNION_operator