SQL 전후 상쇄, 누적 구 화, 다 중 줄 통합

503 단어 데이터 뱅 크
테스트 데이터
with tb as(
select 1 id,25 qty
union all select 2,30
union all select 3,67
union all select 4,17
)

전후 상쇄
select *,(select a.qty-b.qty from tb b where a.id=b.id+1)  
from tb a

반복 해서 화 해 를 구하 다.
select *,(select sum(qty) from tb b where b.id<=a.id)  
from tb a

다 중 병합
select stuff((select ','+cast(qty as varchar) from tb order by qty for xml path('')),1,1,'')

좋은 웹페이지 즐겨찾기