Thursday, May 12, 2016

SQL : Product

For these 2 tables: Product(ProductID, ProductName), Sales(SalesOrderID, ProductID, SaleDate)
- Get the list of Products that were sold last year.
- Get the list of Products that were NOT sold last year.

select * 
from sales as S
inner join product as P
on S.productid = P.productid
where year(s.saledate) = 2015

select * from products
where productid not in (
select productid 
from sales
where year(s.saledate) = 2015
)  



No comments:

Post a Comment