Professional Documents
Culture Documents
I want information on products with weight of less than 10 SELECT * FROM PRODUCT Where NOT (P_Weight between 12.00 and 15.00);
P_Code P_Name P_Description P_Quant_In_Stock P_Reorder_Quant P_Weight P_Price
b1345
Nails
2mm Straight
10
10.00
0.70
*********** B17 **************************************************** Display details of products whose Reorder quantity is more than 2 and Quantity in Stock is more than 5 SELECT * FROM Product WHERE P_Reorder_Quant > 2 AND P_Quant_In_Stock >= 5;
P_Quant_In_Stock 10 30
P_Reorder_Quant 4 10
-- Stage 1: Display details of products and suppliers Select P_Name as Products,supplier.S_Name from product Inner join poitem On product.p_code=poitem.p_code Inner join Purchaseorder On purchaseorder.po_no=poitem.po_no Inner join supplier On supplier.s_no=purchaseorder.s_no;
30. -- Run the instruction and check your results. SELECT * FROM emp WHERE job IN ('SALESMAN', 'MANAGER') AND deptno = 30; -- Stage 3: Display details of those salesmen and managers in dept 30 -- whose salary is greater than or equal to 1,500. SELECT * FROM emp WHERE job IN ('SALESMAN', 'MANAGER') AND deptno = 30 AND sal >= 1500; /* *********** B18 **************************************************** Display the employee number, current job and salary of all those who work in Department 30, with the output in ascending salary order. As before, you may wish to write and test your instruction in a number of stages. */ SELECT empno, job, sal FROM emp WHERE deptno=30 ORDER BY sal ASC; -- ASC is optional as it is the default /* *********** B19 ****************************************************
Display the employee name and current job of all those who work in Department 30, with the output in descending salary order */ SELECT ename, job FROM emp WHERE deptno=30 ORDER BY sal DESC; -- Check carefully as the sorted column is not being displayed. /* *********** B20 **************************************************** Display the employee name, current job and salary of all those who work in Department 30, with the output in descending salary order within each job. */ SELECT ename, job, sal FROM emp WHERE deptno=30 ORDER BY job, sal DESC; -- *** OR*** SELECT ename, job, sal FROM emp WHERE deptno=30 ORDER BY job ASC, sal DESC; /* The question asked for the selected data to be output in descending salary order within each job. Does this influence the best order for displaying the columns? Can you suggest a better solution? SELECT job, sal, ename FROM emp
WHERE deptno=30 ORDER BY job ASC, sal DESC; */ /* *********** B21 **************************************************** Display employee details for departments 10 and 30, in name order, within each department. Display the columns in the most appropriate order. */ SELECT * FROM emp WHERE DEPTNO IN (10, 30) ORDER BY DEPTNO, ENAME; -- Normal to display columns (left to right) in order of sorting -- requirements. SELECT deptno, ename, sal FROM emp WHERE DEPTNO IN (10, 30) ORDER BY DEPTNO, ENAME;
--14/10/08