Get the step-by-step solution for this question inside the Vidyadip app.
Get the answer in the appGenerate a complete, print-ready paper with questions like this in minutes — across 16+ boards, with answer keys.
Table: Bank
| AccNo | Cust_name | FD_Amount | Months | Int_Rate | FD_Date |
| 1001 | Arti Gupta | 30000 | 36 | 6.00 | 2018-07-01 |
| 1002 | Dilip Lal | 50000 | 48 | 6.75 | 2018-03-22 |
| 1003 | Navin Gupta | 30000 | 36 | NULL | 2018-03-01 |
| 1004 | D.P. Yadav | 80000 | 60 | 8.25 | 2017-06-12 |
| 1005 | Jyoti Sharma | 20000 | 36 | 6.50 | 2017-01-31 |
| 1006 | Rakesh Kumar | 70000 | 60 | 8.25 | 2018-06-15 |
| 1007 | K.D. Singh | 50000 | 48 | NULL | 2018-07-05 |
| 1008 | Anjali Sharma | 60000 | 48 | 6.75 | 2017-04-02 |
| 1009 | Swati Garg | 40000 | 42 | 6.50 | 2018-06-15 |
| 1010 | Rupinder Kaur | 25000 | 36 | 6.50 | 2018-09-27 |
Write SQL commands for the statements (a) to (g) on the table BANK
(a) To create the table Bank (Primary Key: AccNo)
(b) Display the structure of the table Bank.
(c) Display the details of all the bank.
(d) Display the AccNo, Cust_Name, and FD_Amount.
(e) Display the details of all the FD’s having maturity time is less than 40 months.
(f) Display the AccNo and FD amount which started before 01-04-2018.
(g) Display details of all FD whose rate of interest are NULL.
Write SQL commands for the following queries based on the relation Teacher given below:
Table: Teacher
| No | Name | Age | Department | Date_of_join | Salary | Sex |
| 1 | Jugal | 34 | Computer | 10/01/97 | 12000 | M |
| 2 | Sharmila | 31 | History | 24/03/98 | 20000 | F |
| 3 | Sandeep | 32 | Maths | 12/12/96 | 30000 | M |
| 4 | Sangeeta | 35 | History | 01/07/99 | 40000 | F |
| 5 | Rakesh | 42 | Maths | 05/09/97 | 25000 | M |
| 6 | Shyam | 50 | History | 27/06/98 | 30000 | M |
| 7 | Shiv Om | 44 | Computer | 25/02/97 | 21000 | M |
| 8 | Shalakha | 33 | Maths | 31/07/97 | 20000 | F |
(a) To show all information about the teacher of Computer department.
(b) To list the names of female teachers who are in Maths department.
(c) To list the names of all teachers with their date of joining in ascending order.
(d) To display teacher ’s name, salary, age for male teachers only.
(e) To count the number of teachers with Age >23.
Write a program to sort the (name, age, height) tuples by ascending order where name is string, age and height are numbers. The tuples are input by the user. The sort criteria is:
1: Sort based on name;
2: Then sort based on age;
3: Then sort by score.
The priority is that name >age >score.
If the following tuples are given as input to the
program:
ram,19,20
Shyam,15,67
Raju,13,90
Rakesh,17,78
Then, the output of the program should be:
[('Raju', '13', '90'), ('Rakesh', '17', '78'), ('Shyam', '15', '67'), ('ram', '19', '20')]
Answer the (a) and (b) on the basis of the following tables STORE and ITEM:
Table: STORE
| SNo | SName | AREA |
| S01 | ABC Computronics | GK II |
| S02 | All Infotech Media | CP |
| S03 | Tech Shoppe | Nehru Place |
| S05 | Hitech Tech Store | CP |
Table: ITEM
| INo | IName | Price | SNo |
| T01 | Mother Board | 12000 | S01 |
| T02 | Hard Disk | 5000 | S01 |
| T03 | Keyboard | 500 | S02 |
| T04 | Mouse | 300 | S01 |
| T05 | Mother Board | 13000 | S02 |
| T06 | Key Board | 400 | S03 |
| T07 | LCD | 6000 | S04 |
| T08 | LCD | 5500 | S05 |
| T09 | Mouse | 350 | S05 |
| T10 | Hard disk | 4500 | S03 |
(a) Write the SQL queries (1 to 4):
(i) To display IName and Price of all the items in the ascending order of their Price.
(ii) To display the SNo and SName or all stores located in CP.
(iii) To display the minimum and maximum price of each IName from the table Item.
(iv) To display the IName, price of all items and their respective SName where they are available.
(b) Write the output of the following SQL commands (i) to (iv):
(i) Select distinct iname from item where price >= 5000;
(ii) Select area, count(*) from store group by area;
(iii) Select count(distinct area) from store;
(iv) Select iname, price*0.05 discount from item where sno in (‘s02 ’, ‘s03 ’);
Write the SQL query questions from (i) to (iv) and write the output of SQL command for questions from (v) to (vii) given below:
| EMPID | FIRST NAME | LAST NAME | ADDRESS | CITY |
| 010 | George | Smith | 83 First Street | Howard |
| 105 | Mary | Jones | 842 Vine Ave. | Losantiville |
| 152 | Sam | Tones | 33 Elm St. | Paris |
| 215 | Sarah | Ackerman | 440 U.S. 110 | Upton |
| 244 | Manila | Sengupta | 24 Friends Street | New Delhi |
| 300 | Robert | Samuel | 9 Fifth Cross | Washington |
| 335 | Henry | Williams | 12 Moore Street | Boston |
| 400 | Rachel | Lee | 121 Harrison St. | New York |
| 441 | Peter | Thompson | 11 Red Road | Paris |
Table: EMPSalary
| EMPID | SALARY | BENEFITS | DESIGNATION |
| 010 | 75000 | 15000 | Manager |
| 105 | 65000 | 15000 | Manager |
| 152 | 80000 | 25000 | Director |
| 215 | 75000 | 12500 | Manager |
| 244 | 50000 | 12000 | Clerk |
| 300 | 45000 | 10000 | Clerk |
| 355 | 40000 | 10000 | Clerk |
| 4000 | 32000 | 7500 | Salesman |
| 441 | 28000 | 7500 | Salesman |
Write the SQL commands for the following :
(i) To show firstname, lastname, address and city of all employees living in paris.
(ii) To display the content of Employees table in ascending order of Firstname.
(iii) To display the firstname,lastname and total salary of all managers from the tables employee and empsalary, where total salary is calculated as
salary+benefits.
(iv) To display the maximum salary among managers and clerks from the table Empsalary.
Give the Output of following SQL commands:
(v) Select firstname, salary from employees, empsalary where designation = ‘Salesman’ and Employees.
empid=Empsalary.empid;
(vi) Select count(distinct designation) from empsalary;
(vii) Select designation, sum(salary) from empsalary group by designation having count(*) >2;