SQL Questions For Journal
SQL Questions For Journal
dno varchar2(5) primary key, dept char(15), city char(15), Insert the following rows in the above table.
StNo integer primary key, Name char(15), Desgn char(15), BS float. Address char[40], dno varchar2(5)
reference key
6. Display details of Staff whose name have the letter ‘a’ in them.
8. Display Name, Stcode, Bs, Comm( BS * .1 ), NS(BS + Comm), department and city of each salesman.
9. Display Name, StNo, BS, allowance(10% of BS) of all Salesmen from the STAFF table.
Ans-SELECT * FROM STAFF WHERE BS*0.1=(SELECT MAX(BS*0.1) FROM STAFF WHERE DESGN='SALESMAN');
10. Display details of salesmen with highest allowance (10% of BS) from the STAFF table.
13. Display details of Employees with salary less than equal to 50000 and greater than equals to 100000.
17. Display the designation and number of designation where number of employees are less than 2.
18. create a table salesmannew where details of all the salesmen are copied.
20. create a view named new view which shows details of staff where BS between 40000 and 100000.
Ans- CREATE VIEW NEWVIEW AS (SELECT * FROM STAFF WHERE BS BETWEEN 40000 AND 100000);
22. Show designation wise average and sum of salary of staff members.
23. Display details of all staff members in ascending order of their names.
24. Display details of all staff members in descending order of their salary.
Ans- ROLLBACK;
27. Add a new column age to the staff table with the default age as 22.
Ans- ALTER TABLE STAFF ADD COLUMN AGE INT DEFAULT 22;
28. Modify the age column in staff table to make it float type.