I am practicing with northwind database: I am quite new to sql. Question I am trying to solve is :
Q. Total Sales for each customer in October 1996 (based on OrderDate). Show the result in CustomerID, CompanyName, and [total sales], sorted in [total sales] in Decending order.
I have used this code but doesn't seems to be correct , please advise.
select c.customerid , c.companyname , o.orderdate , sum(od.unitprice *od.Quantity*1-od.Discount) as totalsales
from customers as c , orders as o , [Order Details] as od
where o.customerid = c.CustomerID
and o.OrderID = od.OrderID
and o.OrderDate >= '1996/10/01' and o.orderdate <= '1996/10/31'
group by c.customerid , c.companyname, o.orderdate
order by totalsales desc
;
*******************************