관리 메뉴

안까먹을라고 쓰는 블로그

[MSSQL] SubQuery 활용 본문

DataBase/MS SQL

[MSSQL] SubQuery 활용

YawnsDuzin 2016. 5. 26. 14:42

 

반응형

select * from tblShipTicket where ShipmentNo in (select ShipmentNo from tblShipPlan where PlanDay between '20160524' and '20160524')

delete from a
--select * 
 from tblLPR_IO a,
(select  IODateTime, IO, TASVehiNo, MAX(seq) as seq from tblLPR_IO
group by IODateTime, IO, TASVehiNo having count(*) > 1) b
where a.IODateTime = b.IODateTime
and a.IO = b.IO
and a.TASVehiNo = b.TASVehiNo
and a.seq != b.seq
UPDATE a
SET
a.Absorb_1 = (b.Val_01 + b.Val_02)
, a.Absorb_2 = (b.Val_03 + b.Val_04)
, a.Absorb_3 = (b.Val_05 + b.Val_06)
, a.Absorb_4 = b.Val_07
FROM absorb_master a
INNER JOIN tblAbsorbMaster_Sub b
ON a.Absorb_Line = b.Line
and a.Absorb_Date = b.Date
and b.Line = @sLine
and b.Date = @sDate


반응형

'DataBase > MS SQL' 카테고리의 다른 글

[MSSQL] 쿼리 종료시간 확인  (0) 2016.05.30
[MSSQL] Lock Log남기기  (0) 2016.05.30
[MSSQL] 사이트 링크  (0) 2016.05.26
[MSSQL] SPLIT 구현  (0) 2016.05.26
[MSSQL] 중복제거  (0) 2016.05.26
Comments