--1 查詢出產品的ID號,產品的名字,產品的零售價,產品的型別名。
--2、查詢出訂單號,下訂單的顧客名字,以及處理的雇員的名字。
--3、查詢出產品的ID號,供應該產品的供應商的名字,以及該產品的批發價。
--4、查詢出產品的名字,供應該產品的供應商的名字,以及該產品的批發價
--5、查詢出產品id為8的產品的銷售總額
--6、查詢出產品的ID號,以及每個產品的總銷售額。
--7、查詢出產品的名字,以及每個產品的總銷售額。
--8、查詢出銷售總額超過2萬的產品的名字以及銷售總額。
--9、查詢出每一大類產品的型別名,以及每類產品的銷售總額。
--10、查詢出訂單號,以及每個訂單號訂購了多少種產品-
-11、查詢訂購的產品種數超過5個的訂單號以及訂購的產品種數。
--12、查詢出訂購產品種類數超過5個的訂單號以及訂單總額。
--13、查詢出每個雇員的ID號以及每個雇員的銷售額--14 查詢出每個雇員的ID號,雇員的名字,以及每個雇員的銷售總額
--15、查詢雇員與顧客住在同一個城市的城市名字、顧客的名字以及雇員的名字。
uj5u.com熱心網友回復:
求大佬回復啊啊啊啊啊啊啊吧uj5u.com熱心網友回復:
內容太多了,幫你頂一下,其實找本基礎的介紹SQL的書看一看,就能做完了
uj5u.com熱心網友回復:
--1 查詢出產品的ID號,產品的名字,產品的零售價,產品的型別名。select p.productnumber,p.productname,p.retailprice,p.quantityonhand,c.categorydescription from products p,categories c where p.categoryid = c.categoryid;
--2、查詢出訂單號,下訂單的顧客名字,以及處理的雇員的名字。
select o.ordernumber,c.custfirstname,c.custlastname,e.empfirstname,e.emplastname from orders o , customers c,employees e where o.employeeid=e.employeeid and o.customerid = c.customerid;
--3、查詢出產品的ID號,供應該產品的供應商的名字,以及該產品的批發價。
select p.productnumber,v.vendname,pv.wholesaleprice from products p ,product_vendors pv ,vendors v where p.productnumber=pv.productnumber and pv.vendorid=v.vendorid ;
--4、查詢出產品的名字,供應該產品的供應商的名字,以及該產品的批發價
select p.productname,v.vendname,pv.wholesaleprice from products p ,product_vendors pv,vendors v where p.productnumber=pv.productnumber and pv.vendorid=v.vendorid ;
--5、查詢出產品id為8的產品的銷售總額
select sum(od.quotedprice*od.quantityordered) from order_details od where od.productnumber=8;
--6、查詢出產品的ID號,以及每個產品的總銷售額。
select od.ordernumber,sum(od.quotedprice*od.quantityordered) from order_details od group by od.ordernumber;
--7、查詢出產品的名字,以及每個產品的總銷售額。
select p.productname,sum(od.quotedprice*od.quantityordered) from products p,order_details od where p.productnumber=od.productnumber group by p.productname;
--8、查詢出銷售總額超過2萬的產品的名字以及銷售總額。
select p.productname,sum(od.quotedprice*od.quantityordered) from products p,order_details od where p.productnumber=od.productnumber group by p.productname having sum(od.quotedprice*od.quantityordered)>20000;
--9、查詢出每一大類產品的型別名,以及每類產品的銷售總額。
select c.categorydescription,sum(od.quotedprice*od.quantityordered) from products p,categories c,order_details od where p.categoryid = c.categoryid and p.productnumber = od.ordernumber group by c.categorydescription;
--10、查詢出訂單號,以及每個訂單號訂購了多少種產品
select od.ordernumber,count(p.categoryid) from order_details od,products p where od.productnumber=p.productnumber group by od.ordernumber;
--11、查詢訂購的產品種數超過5個的訂單號以及訂購的產品種數。
select od.ordernumber,count(p.categoryid) from order_details od,products p where od.productnumber=p.productnumber group by od.ordernumber having count(p.categoryid)>5;
--12、查詢出訂購產品種類數超過5個的訂單號以及訂單總額。
select od.ordernumber,count(p.categoryid),sum(od.quotedprice*od.quantityordered) from order_details od,products p where od.productnumber=p.productnumber group by od.ordernumber having count(p.categoryid)>5;
--13、查詢出每個雇員的ID號以及每個雇員的銷售額
select o.employeeid,sum(od.quotedprice*od.quantityordered) from orders o,order_details od where o.ordernumber=od.ordernumber group by o.employeeid;
--14 查詢出每個雇員的ID號,雇員的名字,以及每個雇員的銷售總額
select o.employeeid,e.empfirstname||' '||e.emplastname,sum(od.quotedprice*od.quantityordered) from orders o,order_details od,employees e where o.ordernumber=od.ordernumber and o.employeeid=e.employeeid group by o.employeeid,e.empfirstname,e.emplastname;
--15、查詢雇員與顧客住在同一個城市的城市名字、顧客的名字以及雇員的名字。
select c.custcity,c.custfirstname||' '||c.custlastname,e.empfirstname||' '||e.emplastname from customers c,employees e where c.custcity=e.empcity;
僅供參考
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/8465.html
標籤:基礎和管理
上一篇:求助:org.hibernate.HibernateException: Dialect class not found
