I have a query where I'm calculating average pallets per order. this is calculated using two select stements 1) calculates the number of of pallets and 2) calculates the number of orders.
I do not get and error but my result is 0 if I repalce the "/" with a multiply "*" or add "+" I get the right calculation but for some reason division returns 0. The expected result is (11 pallets / 23 orders = avg of .48 pallets per order)
Here is the query I have but I'm not sure if what i'm trying to do is possible the way I have in the script
Thanks in advance for any help
RJL
I do not get and error but my result is 0 if I repalce the "/" with a multiply "*" or add "+" I get the right calculation but for some reason division returns 0. The expected result is (11 pallets / 23 orders = avg of .48 pallets per order)
Here is the query I have but I'm not sure if what i'm trying to do is possible the way I have in the script
Code:
SELECT
'AVG_PL_ORDER' =
(SELECT
COUNT(SC.INTERNAL_CONTAINER_NUM) FROM SHIPPING_CONTAINER SC
LEFT OUTER JOIN SHIPMENT_HEADER SH WITH(NOLOCK)
ON SC.INTERNAL_SHIPMENT_NUM = SH.INTERNAL_SHIPMENT_NUM
WHERE SC.CONTAINER_TYPE = 'PL' AND SC.COMPANY = '317' AND SC.WAREHOUSE = '029'
AND CONVERT (VARCHAR(30),SH.ACTUAL_SHIP_DATE_TIME,101)
BETWEEN @STARTDATE AND @ENDDATE)
/
(SELECT
COUNT(DISTINCT SH.INTERNAL_SHIPMENT_NUM)
FROM SHIPMENT_HEADER SH WITH(NOLOCK)
WHERE SH.COMPANY = '317' AND SH.WAREHOUSE = '029'
AND CONVERT (VARCHAR(30),SH.ACTUAL_SHIP_DATE_TIME,101)
BETWEEN @STARTDATE AND @ENDDATE)
Thanks in advance for any help
RJL