Reputation: 1670
I want to make a union to start with WITH, but SQL server won't allow me to do that.
What will be the correct way to do it?
with T1 as
(select * from Table where ID in (1, 2, 3))
select * from T1
UNION
with T2 as
(select * from Table where ID in (7, 8, 9))
select * from T2
Upvotes: 0
Views: 48
Reputation: 1670
I found the syntax is
with T1 as (select * from Table where ID in (1, 2, 3)),
T2 as (select * from Table where ID in (7, 8, 9))
select * from T1
UNION
select * from T2
Upvotes: 1