Forum Discussion
praveshrawat
Nov 27, 2022Copper Contributor
Facing New Challenge in WITH Clause
Hi users, I am facing the challenge to run the below query in 2014 MS Sql server. With Hotels as ( select * from dbo.['2018$'] union select * from dbo.['2019$'] union select * from db...
olafhelper
Nov 28, 2022Bronze Contributor
praveshrawat , and which error message do you get?
First, don't use the asteriks * for all columns in a UNION statement. In a UNION all sub-queries must return the same count of column and the columns must have the same data type.
Is that the complete statement? If not, then you get an error because the final SELECT statement is misssing.
;WITH Hotels AS (...)
select *
from Hotels