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

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -