반응형
--[!]하위커리(서브쿼리)
--3번인데이터의나이보다큰데이터만출력
-- [a] 3번레코드의나이
Select Age From Members Where Num = 3
--[b] 3번레코드의나이보다큰데이터출력
Select *From Members where Age > 30
--[a] 3번레코드의나이--26~29번을개선한것
Declare @intAge Int
Select @intAge = Age From Members Where Num = 3
--[b] 3번레코드의나이보다큰데이터출력
Select *From Members Where Age > @intAge
--[!]최종: 서브쿼리는기본적으로스칼라값이반환되어져야함 --32~36을개선한최종
Select *From Members
Where Age > (Select Age From Members Where Num = 3)
Go
--Select Age From Members Where Num = 3 : 단일값(스칼라값)으로출력
반응형
'DataBase > MS SQL' 카테고리의 다른 글
31.MS_SQL 2008 - GroupBy (0) | 2009.09.14 |
---|---|
30.MS_SQL 2008 - 서브쿼리문 [3] (0) | 2009.09.14 |
28.MS_SQL 2008 - 서브쿼리문 [1] (0) | 2009.09.14 |
27.MS_SQL 2008 - Join_Left(조인문) [3] (0) | 2009.09.14 |
26.MS_SQL 2008 - Join_Left(조인문) [2] (0) | 2009.09.14 |
Comments