Group by issue in sql server -


this question has answer here:

hi have written query display sum of quantity follows without group by

select isnull(sum(vuitems.quantity), 0) orderqty   vuitems  

this returns 0.00 same query when using group by not displaying 0.00 might problem

select isnull(sum(vuitems.quantity), 0) orderqty   vuitems group  sku,           salesorderno  

why need have table have quantity on saving have written display quantity ordered or user eneterd follows

select vu1.*,        vu1.quantity - (select isnull(sum(vu2.quantity), 0) orderqty                          vu2                         vu1.sku = vu2.sku                               , vu1.salesorderno = vu2.salesorderno                        group  sku) orderedquantity   vu1  

with out group displaying orderedquantity required group showing null

the isnull needs inside sum. sum(null) null.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -