Open larcher15 opened 6 years ago
TEST CODE:
with cte as ( select count(distinct soh.customerid) as count_of_customers_ordered ,eomonth(soh.orderdate) as order_month from sales.SalesOrderHeader soh inner join sales.SalesOrderDetail sod on sod.SalesOrderID = soh.SalesOrderID inner join production.product p on sod.ProductID = p.productid where isnull(p.color,'missing') in ('red','black','missing','blue','silver') group by eomonth(soh.orderdate) ) -- this is my test code /The years should be: 1216 2005 3094 2006 9864 2007/ select sum(count_of_customers_ordered) ,year(order_month) from cte group by year(order_month) -- the ouput looks correct
This is done because bla bla bla