다음과 같은 데이터가있는 테이블이 있습니다.
branch day amount discount gst
001 4 300.00 130.00 9.32
001 10 200.12 211.00 18.00
001 30 343.22 122.00 8.22
002 12 423.00 123.00 8.00
005 2 453.21 232.11 9.99
005 12 111.21 99.00 0.21
005 27 321.99 12.00 0.00
vb.net을 사용하여 테이블에 값을 삽입하여 누락 된 날을 채우고 싶습니다.
branch day amount discount gst
001 1 0.00 0.00 0.00
001 2 0.00 0.00 0.00
001 3 0.00 0.00 0.00
001 4 300.00 130.00 9.32
001 5 0.00 0.00 0.00
001 6 0.00 0.00 0.00
001 7 0.00 0.00 0.00
001 8 0.00 0.00 0.00
001 9 0.00 0.00 0.00
001 10 200.12 211.00 18.00
.......
총 일수는 dayinmonth에서 가져옵니다.
업데이트 :
다음과 같이 고려합니다.
* 일별 첫 주문 테이블 선택
jj = 1
while jj <> DaysInMonth(mth, yr)
if jj <> rowTable.item("day")
* insert the value here.
jj = jj + 1
end if
이 쿼리 시도
declare @tab table(branch varchar(3), day int, amount float) ;
insert into @tab values
('001',4,300.00),
('001',10,200.12),
('001',30,343.22),
('002',12,423.00),
('005',2,453.21),
('005',12,111.21),
('005',27,321.99);
with month_days as
(select t.number,t1.branch from (select number from master..spt_values where type='P' and number between 1 and 30) t cross join (select distinct branch from @tab)t1)
select md.branch,number as day,isnull(amount,0) amount from @tab t right join month_days md on t.day=md.number and t.branch=md.branch;
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다