sql - Stock ledger query from one table -
i have table
documentnumber, itemnumber, qty, ----------------------------------- 600000001, 1006yl01, 1 100001976, 1006yl01, -1 100008439, 1006yl08, -1 600000001, 1006yl08, 1 100005095, 1006yl08, -1 100003814, 1006yl08, -1 100002955, 1006yl08, -1 500000087, 1006yl08, 2 500000212, 1006yl08, 1 100001152, 1006yl09, -1 100004799, 1006yl09, -1 500000282, 1006yl09, 2 100002859, 1006yl09, -1 600000001, 1006yl09, 2 100003625, 1006yl09, -1 600000001, 1006yl10, 2 100003274, 1006yl10, -1 100002451, 1006yl10, -1
i want make query returns
document number, itemnumber, receiveqty (from qty >1), issue qty (from qty<1)
can body help?
select documentnumber, itemnumber, sum(case when qty > 1 1 else 0 end) total_lessthanone, sum(case when qty < 1 1 else 0 end) total_greaterthanone tablename group documentnumber, itemnumber
Comments
Post a Comment