Hi, I currently studying computer science 1st year and I have trouble with practice exercise because I got exam tomorrow can you guys help me Here is my question:
I have done some sql query am not sure It correct or not
ITEM(INO integer, INAME: varchar(10), DEPT: integer, PRICE: float, QTY:integer, COST:float)
EMP(ENO: integer, ENAME: varchar(15), SALARY: integer, COMM: integer, DEPT: integer)
DEPT(DNO: integer, DNAME: varchar(10), FLOOR: integer, MANAGER: integer)
SALE(INO integer,ENO: integer,STIME: date, QTY: integer, PRICE: float)
1) Retrieve the item number, item name and total sale value of all the item sold in the current year ( sale value is the product of QTY and Price of sale)
Ans
Select INO, INAME, SUM(QTY + PRICE) As totalSale
from Item, SALE
Where sale.STIME = (select to_char(systdate, 'YYYY') STIME
from SALE
)
2) Find the employee who receives the highest commission in each department. Display the DNO, ENAME and COMM
Ans
select DNO, ENAME, COMM
from EMP, DEPT
where EMP.COMM = ( select MAX(COMM), b.DNO
from EMP, DEPT b, DEPT A
Where b.DON = a.DNO
)
3) Find the department that offer less than ten different items. Display DNO, DNAME, floor and number of item
ANS
select: DNO, DNAME, FLOOR, SUM(QTY) as NumItem
from: DEPT, ITEM
where: DEPT < 10
Thank