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.
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;
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 ’;
Write the complete steps to sort the above along with each pass explanation.
| From_To | FlightNumber | RecentDelays | Airline | |
| 0 | NewDelhi_Chennai | 10045.0 | [23, 47] | Spicejet |
| 1 | Mumbai_NewDelhi | NaN | [] | Indigo |
| 2 | Jaipur_Jammu | 10065.0 | [24, 43, 87] | Spicejet |
| 3 | Chennai_Lucknow | NaN | [13] | Indian Airlines |
| 4 | Mumnbai_Chennai | 10085.0 | [67, 32] | Spicejet |
(i) #To display the maximum flight number
(ii) #To print the number of flights airline wise
(iii) #to drop the nan values from the dataframe
(iv) To fill nan with blank values
(v) To print the maximum values of recent delays
(vi) To print the median of all the numeric values.
(vii) To print the sum of the recentdelays
(viii) To count the flight numbers.
(ix) To print the airline wise the sum of the recentdelays along with From_to as column
(x) To print the airline wise the sum of the recentdelays along with From_to as column. Also fill NaN values as blank.