sql server - SQL with Left Join showing values that are zero -


i have sql query setup want ignore 0's in min_on_hand column, , can't seem figure out why doesn't work

select       sku_master.sku,      sku_master.description,      sku_master.min_on_hand,     sku_master.max_on_hand,      x.total_qty_on_hand       [fci].dbo.[sku_master]  left join     (select           sku_master.sku,           sum(location_inventory.qty_on_hand) total_qty_on_hand                 [fci].[dbo].[location_inventory]       join           [fci].dbo.[sku_master] on location_inventory.sku = sku_master.sku                sku_master.min_on_hand > 0       group           sku_master.sku) x on sku_master.sku = x.sku; 

as others have mentioned in comments, filtering on min_on_hand in subquery has no effect - you'll still returned values in sku_master, won't include of data x.

if move check main query not see records min_on_hand = 0

select       sku_master.sku,      sku_master.description,      sku_master.min_on_hand,     sku_master.max_on_hand,      x.total_qty_on_hand       [fci].dbo.[sku_master]  left join     (select           sku_master.sku,           sum(location_inventory.qty_on_hand) total_qty_on_hand                 [fci].[dbo].[location_inventory]       join           [fci].dbo.[sku_master] on location_inventory.sku = sku_master.sku      group           sku_master.sku) x on sku_master.sku = x.sku      sku_master.min_on_hand > 0  

Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -