MYSQL Assignments
MYSQL Assignments
Assignment -1
SQL Commands)
Q-1 Write SQL Command for (a) to (o) and output of (p)
TABLE : GRADUATE
S.NO NAME STIPEND SUBJECT AVERAGE DIVISION
f. To insert a new 11th row in the GRADUATE table:(11,”KAJOL”, 300, “Comp Sc”,
75, 1)x
Using NULL
9. Display the details of all the loans whose rate of interest is NULL.
10. Display the details of all the loans whose rate of interest is not NULL.
Using DISTINCT Clause
11. Display the amounts of various loans from the table
Loan_Accounts. A loan amount should appear only once.
14. Display the Cust_Name and Loan_Amount for all the loans
which do not have number of instalments 36.
15. Display the Cust_Name and Loan_Amount for all the loans for
which the loan amount is less than 500000 or int_rate is more than 12.
16. Display the details of all the loans which started in the year 2009.
18. Display the details of all the loans whose rate of interest is in the range 11%
to 12%.
Using IN Operator
19. Display the Cust_Name and Loan_Amount for all the loans for
which the number of instalments are 24, 36, or 48. (Using IN
operator)
21. Display the details of all the loans whose rate of interest is
in the range 11% to 12%. (Using BETWEEN operator)
23. Display the AccNo, Cust_Name, and Loan_Amount for all the loans
for which the Cust_Name ends with 'a'.
24. Display the AccNo, Cust_Name, and Loan_Amount for all the loans
for which the Cust_Name contains 'a'
25. Display the AccNo, Cust_Name, and Loan_Amount for all the loans
for which the Cust_Name does not contain 'P'.
26. Display the AccNo, Cust_Name, and Loan_Amount for all the loans
for which the Cust_Name contains 'a' as the second last character.
28. Display the details of all the loans in the descending order of their
Start_Date.
29. Display the details of all the loans in the ascending order
of their Loan_Amount and within Loan_Amount in the
descending order of their Start_Date.
31. Increase the interest rate by 0.5% for all the loans for which
the loan amount is more than 400000.
33. Delete the records of all the loans whose start date is before 2007.
34. Delete the records of all the loans of 'K.P. Jain'
35. Add another column Category of type CHAR(1) in the Loan table.
2. Create the table WORKER and add records as shown below. Write
SQL commands for the statements (a) to (g).
a. To display the details in ascending order of salary.
e
711 KESHAR 40000 WEST 45 C CIVIL
262 KIRTI 35000 SOUTH 38 A ELEC
693 KRIPPLE 60000 NORTH 52 B CIVIL
724 ARYAN 38000 NORTH 29 B CIVIL
705 SAMSON 42000 EAST 35 A COMP
606 BISWAL 29000 SOUTH 34 A MECH
a. To display the list of all employees in ascending order of salary.
b. To display the employee names in descending order of age.
With reference to these tables, Write commands in SQL for (a) and (b) and
output for (c) below:
a. Display the CustNo, CustAddress and corresponding SetName for each
customer.
b. Display the Customer Details for each customer who uses a Nokia handset.
GIVE OUTPUTS
e. SELECT DISTINCT SenderCity FROM sender;
c. To display the ClientName, City from table Client, and ProductName and
Price from table Product, with their corresponding matching P_ID.
6. (II) Create the following tables WORKER and PAYLEVEL. Write SQL
commands for the statements (a) to (d) and give outputs for SQL queries
(e) to (h)
Table: WORKER
EC NA DESIG PLE D D
O ME V O O
D E J B
E L
11 Radhe Shyam Supervisor P001 13-Sep-2004 23-Aug-
1981
12 Chander Nath Operator P003 22-Feb-2010 12-Jul-1987
13 Fizza Operator P003 14-Jun-2009 14-Oct-1983
15 Ameen Ahmed Mechanic P002 21-Aug-2006 13-Mar-
1984
18 Sanya Clerk P002 19-Dec-2005 09-Jun-1983
Table: PAYLEVEL
PLEVE PA ALLOW
L Y AN
CE
P001 260 12000
00
P002 220 10000
00
P003 120 6000
00
OUTPUT—-----------
c. Display all the records from a table Student.
OUTPUT—------
OUTPUT—------
b. Input Rollno and delete the corresponding record from the table
Student.
OUTPUT—------
c. Display all the records of a grade entered by the user from the table
Student.
OUTPUT—------
d. Display all the records in descending order of total marks from the table
Student.
OUTPUT—-----