Created
January 14, 2018 20:08
-
-
Save agawronski/69e2bb8ae241ddca86b7011d4b4bdf95 to your computer and use it in GitHub Desktop.
What is the average number of orders purchased across all vendors? What is the average cost across all vendors?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select | |
avg(i.num_orders) as average_num_orders, | |
avg(i.subtotal) as average_subtotal | |
from ( | |
select | |
y.name, | |
count(distinct x.purchaseorderid) as num_orders, | |
sum(x.subtotal) as subtotal | |
from purchasing.purchaseorderheader x | |
left join purchasing.vendor y | |
on x.vendorid = y.businessentityid | |
group by y.name | |
) i; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment