Morpheus7
asked on
Calculations
I have a table that contains the the following fields:
Order number , product code and quantity. Most of the orders have multiple lines.
What would be the best way to determine the following:
Total number of orders
Number of orders that have
1-5 items
5-20 items
20-50 items
50 plus items
Also average number of products per order,
Average number of items per order
Any help would be appreciated
Thanks
Order number , product code and quantity. Most of the orders have multiple lines.
What would be the best way to determine the following:
Total number of orders
Number of orders that have
1-5 items
5-20 items
20-50 items
50 plus items
Also average number of products per order,
Average number of items per order
Any help would be appreciated
Thanks
By "items" are you referring to the quantity? As in quantity of items?
here's a start
select
num_of_orders
, num_of_products
, tot_rows / num_of_orders as avg_items_per_order
from (
select
count(*) as tot_rows
, count(distinct [Order number]) as num_of_orders
, count(distinct [product code]) as num_of_products
from sometable
) as derived
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.