Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Get some basic metrics on the purchaseorderdetail table.
-- what is APT, and UPT, APU
-- average per transaction
-- units per transaction
-- average per unit
select
(sum(orderqty * unitprice)/count(distinct purchaseorderid)) as apt,
(sum(orderqty)/count(distinct purchaseorderid)) as upt,
(sum(orderqty * unitprice)/sum(orderqty)) as apu
from purchasing.purchaseorderdetail;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment