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