With TEST As (Select a=1 Union Select a=2 Union Select a=3)
Select a+10 From TEST Where a < 2 union Select a+20 From TEST Where a > 2
위 두번째 줄에서 Union을 사용하지 않고 다른 조건절을 사용해서 동일한 결과를 가져올 수 없나요?
Comment 1
-
지영아빠
2022.11.26 22:29
With TEST As (Select a=1 Union Select a=2 Union Select a=3)
Select a+10 From TEST Where a < 2 union Select a+20 From TEST Where a > 2
위 두번째 줄에서 Union을 사용하지 않고 다른 조건절을 사용해서 동일한 결과를 가져올 수 없나요?
2022.11.26 22:29
이런건 어떨까요?
With TEST As (Select a=1 Union Select a=2 Union Select a=3)
select
a + case a when 1 then 10 else 20 end
From TEST
where a > 2 or a < 2
With TEST As (Select a=1 Union Select a=2 Union Select a=3)
select
a + case a when 1 then 10 else 20 end
From TEST
where a in (1, 3)
With TEST As (Select a=1 Union Select a=2 Union Select a=3)
select
y.c
From TEST x
inner join (select 1 as b, 11 as c union all
select 3, 23) y
on x.a = y.b