Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- select distinct item from arias
- select f.item, f.qty, f.amount, sum(x.qty), sum(x.amount),
- f.qty-sum(x.qty), f.amount-sum(x.amount)
- from
- ( select * from x17cnn where month(date)=12 ) x join arias f
- on x.item=f.item
- group by f.item, f.qty, f.amount
- 555480
- select top 10 * from x17cnn where month(date)=12
- select * into #t from
- (select distinct item, name from b17cnn where supp='690'
- union select distinct item, name from b16cnn where supp='690'
- union select distinct item, name from b15cnn where supp='690') t
- go
- select supp, sum(amount) from b17cnn
- where item in (select item from #t)
- group by supp
- select x.item, sum(amount) from
- ( select * from x17cnn where month(date)=12 ) x join #t t on x.item=t.item
- group by x.item with rollup
- order by x.item
- select f.item, sum(x.amount)
- from ( select * from x17cnn where month(date)=12 ) x join arias f
- on x.item=f.item
- group by f.item with rollup
- order by f.item
- select a.*, b_amt, a_amt-isnull(b_amt,0) diff into #a from
- ( select f.item, sum(x.amount) a_amt
- from ( select * from x17cnn where month(date)=12 ) x join arias f
- on x.item=f.item
- group by f.item ) a
- left join
- ( select x.item, sum(amount) b_amt from
- ( select * from x17cnn where month(date)=12 ) x join #t t on x.item=t.item
- group by x.item ) b
- on a.item=b.item where a_amt-isnull(b_amt,0) !=0
- select f.item, sum(x.amount) a_amt
- from ( select * from x17cnn where month(date)=12 ) x join arias f
- on x.item=f.item
- group by f.item with rollup
- select item, name, sum(qty), sum(amount) from x17cnn where item in
- (select item from #b)
- group by item, name
- select * from b17cnn where item in
- ('315.0116')
- select * from arias where item='315.0116'
- select month(date), sum(amount) from x17cnn where item in (select item from #t)
- group by month(date)
- select * from b17cnn where item='315.0116'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement