In: Computer Science
Import the northwind database and write sql statements for the following:
select DISTINCT SupplierID from Products;
select ProductName,SupplierID from Products where UnitPrice > 20;
select * from Products where ProductName like 'c%' and Discontinued = 0;
select Country,COUNT(SupplierID) from Suppliers group by Country;
select s.SupplierID,s.ContactName,COUNT(p.ProductID) as "NumOfProducts",AVG(p.UnitPrice) as "AvgPrice" from Products as p,Suppliers as s where p.SupplierID=s.SupplierID group by s.SupplierID;
select s.ContactName,s.City,s.Country from Products as p,Suppliers as s where p.SupplierID=s.SupplierID and p.Discontinued=0;
select s.SupplierID,s.ContactName from Products as p,Suppliers as s where p.SupplierID=s.SupplierID group by s.SupplierID having COUNT(p.ProductID)>=2;
Here I am inserting sample value:
insert into Products(ProductID,ProductName,SupplierID,CategoryID) values(78,'Coffee',1,1);
update Products set ReorderLevel=ReorderLevel+(0.2*ReorderLevel),UnitPrice=UnitPrice-(0.1*UnitPrice);
delete from Products where Discontinued=1;