--7
select MONTH(Orders.OrderDate), Year(Orders.OrderDate), ProductName from Products,Orders
where
not exists(
select * from Orders o join [Order Details] on o.OrderID=[Order Details].OrderID
and MONTH(o.OrderDate)=MONTH(Orders.OrderDate) and Year(o.OrderDate)=Year(Orders.OrderDate) and Products.ProductID=[Order Details].ProductID
)
group by
MONTH(Orders.OrderDate), Year(Orders.OrderDate), ProductName
order by 2,1
--8
select MONTH(Orders.OrderDate) m, Year(Orders.OrderDate) y, ProductName from Products,Orders
except
select MONTH(o.OrderDate), Year(o.OrderDate), ProductName from
Customers c join Orders o on o.CustomerID=c.CustomerID
join [Order Details] od on o.OrderID=od.OrderId
join Products p on p.ProductID=od.ProductID
--9
select m,y,COUNT(*) from
(select MONTH(Orders.OrderDate) m, Year(Orders.OrderDate) y, ProductName p from Products,Orders
where
not exists(
select * from Orders o join [Order Details] on o.OrderID=[Order Details].OrderID
and MONTH(o.OrderDate)=MONTH(Orders.OrderDate) and Year(o.OrderDate)=Year(Orders.OrderDate) and Products.ProductID=[Order Details].ProductID
)
group by MONTH(Orders.OrderDate), Year(Orders.OrderDate), ProductName) q
group by m,y
Wyszukiwarka
Podobne podstrony:
lab10(1)lab10I9G1S1 Nadolny Michal Lab10lab10lab10 Verilogfiza lab10lab10AiP Lab10sop 2009 lab10lab10Lab10 occi2 lab10lab10 macierze wektorylab10 ACpanek LAB10lab10Lab10 RSVPLab10 integracja z ms?cesswięcej podobnych podstron