mysql - Use SUM of colum values condition in select query with another condition -
i have table called stock.it have columns named item_id
, 'qty'
, 'branch_id'
. need select item ids sum of 'qty' column grater 0 , branch_id equal 4.
i have try query need view item_id column
. prints total
column too.
select `item_id`, sum(`qty`) total `stock` group `item_id` having total > 0 , branch_id = 4
help please.
try query group clause , having
select b.item_id ( select item_id, sum(qty) total stock branch_id = 4 group item_id having total > 0 ) b
or query:
select item_id stock branch_id = 4 group item_id having sum(qty) > 0
Comments
Post a Comment