Skip to content

Instantly share code, notes, and snippets.

@agawronski
Created December 11, 2017 05:32
Show Gist options
  • Save agawronski/6813a4a31a3c879a0e5569e0c1f232f8 to your computer and use it in GitHub Desktop.
Save agawronski/6813a4a31a3c879a0e5569e0c1f232f8 to your computer and use it in GitHub Desktop.
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