asp.net - View all data from a GROUP BY statement -
i demonstrate simple example of issue instead of viewing long sql query project.
my example like:
select deliveryaddressid, pickupdate, totalweight, count(deliveryaddressid) packages deliverydb date1 >= '10-12-2013' , date2 <= '15-12-2013' group pickupdate, deliveryaddressid
my result like:
what want achieve deliveryaddressid 4 packages still keep total numbers. this.
what want expected result:
the reason want because in way able track barcode each package , able track more details.
cheers :-)
in databases, can using window functions:
select deliveryaddressid, pickupdate, totalweight, count(deliveryaddressid) on (partition pickupdate, deliveryaddressid) packages deliverydb date1 >= '10-12-2013' , date2 <= '15-12-2013';
this return total on 4 lines.
edit:
you can handle totalweight
(which not part of original question) same way:
select deliveryaddressid, pickupdate, count(deliveryaddressid) on (partition pickupdate, deliveryaddressid) packages, ceiling(sum(case when (weight <> 0 , volumen <> 0) , weight >= (volumen * @zerovolufac) weight end) on (partition pickupdate, deliveryaddressid) ) totalweight deliverydb date1 >= '10-12-2013' , date2 <= '15-12-2013';
Comments
Post a Comment