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: HOSPITAL
| PNo | Name | Age | Department | DateofAdm | Charges | Sex |
| 1 | Mayank | 65 | Surgery | 23/02/2018 | 600 | M |
| 2 | Babita | 24 | ENT | 01/01/2019 | 400 | F |
| 3 | Kashish | 45 | Orthopaedic | 19/12/2018 | 400 | M |
| 4 | Tarun | 12 | Surgery | 01/10/2018 | 600 | M |
| 5 | Manisha | 36 | ENT | 12/01/2018 | 400 | F |
| 6 | Imran | 16 | ENT | 24/02/2018 | 400 | M |
| 7 | Ankita | NULL | Cardiology | 20/08/2018 | 800 | F |
| 8 | Zoya | 45 | Gynecology | 22/02/2018 | 500 | F |
| 9 | Kush | 19 | Cardiology | 13/01/2019 | 800 | M |
| 10 | Shalini | 31 | Medicine | 19/02/2018 | 300 | F |
Note: PNo is the primary key in the above table.
Write SQL commands for the statements (a) to (g) on the table HOSPITAL.
(a) To show all the information about the patients of the cardiology department.
(b) To list the names of female patients who are either in the orthopaedic or surgery department.
(c) To list the name of all the patients with their date of admission in ascending order.
(d) To display the patient’s name, charges, the age for female patients only.
(e) To count the number of patients with age > 30.
(f) To display various departments.
(g) To display the number of patients in each department.
For example:If the list CITIES contains[“AHMEDABAD”,”CHENNAI”,”NEW DELHI”,”AMRITSAR”,”AGRA”]The following should get displayedAHEMDABADAMRITSARAGRA
Consider the following tables CARHUB and CUSTOMER and answer (a) and (b) parts of this question:
Table: CARHUB
| Vcode | VehicleName | Make | Color | Capacity | Charges |
| 100 | Innova | Toyota | WHITE | 7 | 15 |
| 102 | SX4 | Suzuki | BLUE | 4 | 14 |
| 104 | C Class | Mercedes | RED | 4 | 35 |
| 105 | A-Star | Suzuki | WHITE | 3 | 14 |
| 108 | Indigo | Tata | SILVER | 3 | 12 |
Table: CUSTOMER
| CCode | CName | VCode |
| 1 | Hemant Sahu | 101 |
| 2 | Raj Lal | 108 |
| 3 | Feroza Shah | 105 |
| 4 | Ketan Dhal | 104 |
(a) Write SQL commands for the following statements:
(i) To display the names of all white colored vehicles
(ii) To display name of vehicle, make and capacity of vehicles in ascending order of their sitting capacity
(iii) To display the highest charges at which a vehicle can be hired from CARHUB.
(iv) To display the customer name and the corresponding name of the vehicle hired by them.
(b) Give the output of the following SQL queries:
(i) Select count(distinct make) from cabhub;
(ii) Select max(charges), min(charges) from carhub;
(iii) Select count(*), make from carhub;
(Iv) Select vehiclename from carhub where capacity = 4;
Consider the following tables WORKER and PAYLEVEL and answer (a) and (b) parts of this question:
Relation: WORKER
| ECODE | NAME | DESIG | PAYLEVEL | DOJ | DOB |
| 11 | Radhey 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-June-2009 | 14-Oct-1983 |
| 15 | Ameen Ahmed | Mechanic | P002 | 21-Aug-2006 | 13-Mar-1984 |
| 18 | Sanya | Clerk | P002 | 19-Dec-2005 | 09-June-1983 |
Relation: PAYLEVEL
| PAYLEVEL | PAY | ALLOWANCE |
| P001 | 26000 | 12000 |
| P002 | 22000 | 10000 |
| P003 | 12000 | 6000 |
(a) Write SQL commands for the following statements:
(i) To display the details of all WORKERs in descending order of DOB.
(ii) To display NAME and DESIG of those WORKERs whose PLEVEL is either P001 or P002.
(iii) To display the content of all the WORKERs table, whose DOB is in between ’19-JAN- 1984 ’and ’18-JAN-1987 ’.
(iv) To add a new row with the following: 19, ‘Daya kishore ’, ‘Operator ’, ‘P003 ’, ’19-Jun-2008 ’, ’11-Jul-1984 ’
(b) Give the output of the following SQL queries:
(i) Select count(plevel), plevel from worker group by plevel;
(ii) Select max(dob), min(doj) from worker;
(iii) Select name, pay from worker w, paylevel p where w.plevel=p.plevel and w.ecode <13;
(iv) Select plevel, pay+allowance from paylevel where plevel=’p003 ’;
The program is to be implemented to sub plot