Advertisement
Guest User

Untitled

a guest
Jan 30th, 2015
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 0.60 KB | None | 0 0
  1. select tr.Item, tr.CribBin, tr.user1, i.Description1, tr.IssuedTo, tr.User2, count(tr.user2) as TransCount, sum(tr.quantity) as SumQuantity
  2. from trans tr (nolock) left join inventry i (nolock) on tr.Item = i.ItemNumber
  3. where tr.Transdate > '11-01-2014' and tr.Transdate < '11-30-2014'
  4.     and i.Description1 like '%blank%'
  5.     and tr.user2 is not null
  6.     and tr.TypeDescription in ('ISSUE', 'RETNW')
  7. group by tr.Item, tr.CribBin, tr.user1, i.Description1, tr.IssuedTo, tr.User2
  8. having  count(tr.user2) > 1 --multiple issues for same account case
  9.     and sum(tr.quantity) > 0 --transaction doesnt count if issue and return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement