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.
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;
Table: ITEMS
| CODE | INAME | QTY | PRICE | COMPANY | TCODE |
| 1001 |
DIGITAL PAD 12i |
120 | 11000 | XENITA | T01 |
| 1006 |
LED SCREEN 40 |
70 | 38000 | SANTORA | T02 |
| 1004 |
CAR GPS SYSTEM |
50 | 21500 | GEOKNOW | T01 |
| 1003 |
DIGITAL CAMERA 12X |
160 | 8000 | DIGICLICK | T02 |
| 1005 |
PEN DRIVE 32GB |
600 | 1200 | STOREHOME | T03 |
Table: TRADERS
| TCode | TName | CITY |
| T01 | ELECTRONIC SALES | MUMBAI |
| T03 | BUSY STORE CORP | DELHI |
| T02 | DISP HOUSE INC | CHENNAI |
(a) To display the details of all the items in the ascending order of item names (i.e. INAME).
(b) To display item name and price of all those items, whose price is in range of 10000 and 22000 (both values inclusive).
(c) To display the number of items, which are traded by each trader. The expected output of this query should be:
T01 2
T02 2
T03 1
(d) To display the price, item name and quantity (i.e. qty) of those items which have quantity more than 150.
(e) To display the names of those traders, who are either from DELHI or from MUMBAI.
(f) To display the names of the companies and the names of the items in descending order of company names.
(g1) Select max(price), min(price) from items;
(g2) Select price*qty amount from items where code=1004;
(g3) Select distinct tcode from items;
(g4) Select iname, tname from items i, traders t where i.tcode=t.tcode and qty <100;