You are on page 1of 8
Type B : Application Based Questions Following questions are based on these tables : Table BOOK_INFORMATION Table SALES Column Name Column Name BOOK ID BOOK TITLE PRICE SALES_AMOUNT Table EXAM_RESULTS STUID FNAME LNAME, EXAM 1D | EXAM, SCORE 10 LAURA LYNCH 1 90 10 LAURA LYNCH 2 85. 11 GRACE BROWN, 1 78 u GRACE BROWN, 2 72 2 JAY JACKSON 1 oa 12 JAY JACKSON 2 92. 13 WILLIAM _| BISHOP 1 70 13 WILLIAM _| BISHOP 2 at 14 CHARLES | PRADA 2 = 4 0R0UPNG RECORDS, OMS IN SL 613 _ oy sXe X(PRICE)FROW BOOK MFoRNATION; _ ee aS alge NN eee sign or : saa os ee ere srs ean a 4. vich SQL statement lets you find the ftal ruber of stores in the SALES tbe? (@ sttecr cou(stoRe_10) Fm SALES: ( setect count(oxSTINCT STORE 10) FROM SALES; (0) SELECT DISTINCT STORE_X0 FROM SALES; (@ sexect counr(sroRe_10) FROM SALES GROUP BY STORE_1P; Recency hr wale ent ot Se 1D 5 ane ee) amount for tore ID 45? (e) setecr stone 10, Sun(SALES_AAONT) FROM SALES ‘lene sTone_3D 14 (25,45) GROUP BY STORE TOS (© SeLecr stone x0, suN(SALES_AAOUNT) FROM SALES ‘iOUP By STORE_IO HAVING STORE_X0 IN (25,48) (6) Se.ectstonE_1D, SUM(SALES_AMOUNT) FROM SALES WERE (@, SELECT sToRE_xD, sus(SALES_AMOUNT) FROM SALES. ‘Wine stone 10 = 25 do STORE_10 = 45 GRO BY STORE1D; es at OL tenet do we eo th average exam se or EXAMLIP (©) SELECT avecexan_ScORE) FROM EXAM RESULTS: 0) sett avec scone OH BUN RESIS GO? et ave(5ur Scone) Fn x RESULTS PY EA. ID WE ‘CUNT EXM_SCORE) FROM EXRESULTS ‘sTone_30 16 (25,45)3 “0 by EXAM ID MERE XML = 2 aD 3s eRe UML ID #5 to find out how many students took each exam? 7. Which SQL statement do we use : (@) SELECT COUNT(OISTINCT STU_ID) FROM EXAM RESULTS GROUP BY EXAM_ID; ‘nax(TU_IO) FROM EXAM_RESULTS GROUP BY EXAM_ID; (SELECT EXAMLID, COUNT(OISTINCT STU_ID) FROM EXAH_RESULTS GROUP BY EXAM 10; (0, SELECT ExALID, (@) SELECT EXAY_TO, NIN(STU_ID) FROM EXAM_RESULTS GROUP BY EXAM_ID; 8, What SQL statement do we use to print out the record of all students whose last name starts with (@) SELECT * FROM EXAM RESULTS WHERE LNAME LIKE “LX? (@) SELECT * FROM EXAM_RESULTS WHERE LNAME LIKE ‘L?5 (9) SELECT * FROM EXAM_RESULTS WHERE LNAME = “L's (@) SELECT * FROM EXAM_RESULTS WHERE LNANE <> ‘L?s 9. What is the result of the following SQL. statement? SELECT WOX(EXAM_SCORE) FROM EXAM RESULTS GROUP BY EXAM_IO HAVING EXAY_ID = 3; @9 (0) 85 (2) 100, 95 10, Given the following table Table : CLUB concitio | concuname | ace | sports | parorape | pay | sex | xuxrsa | a5_| karate zrnsise6 | 100 | Mm 2 | ravina | a4” | KARATE aoovises | i200 | F a [karan | a4_[ savas x9en%s | 2000 | 4 | taruy [33 [oasxersaut | ovoviess [as | a 5. ZUBIN: 36__| SWIMMING 12/01/1998 730 M s | wera | x [swnoanc | omnes | ao Tar Zz | anera | 39 | squasit 2oparises | 200 |e 5] ZAREEN | 37_| karare 2202996 | n100 | F 2 an < anes rss | soo | M matt | ispnsse | a7 | M ry RECORDS, JOINS IN SQL on 615 sowing le: oo Table : STUDENT | Mane _| Sepend_| _streem 1 _angMart_|_ Grote | _ cis. 7 [xan _ato0o _| Meinl ms | 8 | Tain | 000 [comnee | wa [x | ue Tops | 2000 [commer | aes |e | ae + [a 20000 [Humannes| aa o| ee Be + Fs | oan [Nomeiat | sos [Af a [ie 0000 | Medial ma | 8 | 2 + Travee | 2000 [vimanues | aa fc | a Len | _asom | Nensason [ses | | ta + Vias [stato [Nemesis [seo a [| A Vaan | om [connee | os | _¢ | ue que opet offllowing SOL statements: My SCT MIN(Avgoas) FROM STUDENT WHERE Ava <757 (peieCt SUMCspend) FROM Stade! WHERE Grade = 2 Gpstsct AvGttipend) FROM Staent WHERE Cas = 24"; fej ECT. COUNTIDISTINCD FROM Student “eat here neo ibe gen ba: Table £108 a2} {ton | President 20000 102. | Vice Presiden 12st) “Raiinittion Assistant yy 2 5, Consider the following tables Employee and Salary. Write SQL. commands for thea wea ‘give outputs for SQL queries (v) to (ci) Diy Table : Employee Pd 1_| Deepali Gupta 101 MCA F 2_| Rajat Tyagi 101 BCA M 3_| Hari Mohan 102 BA, M | Ha 102 MA, M [_s_| Sumit Mival 103 BlTech. M 6 Jyoti 101 MTech F slelels |e |B 6 | 10000 0 (9 To dgplay the frequency of employees departent wie (i) Tolis the names of those employees ony whose name sats with ‘H Gi) To adda new cok in sary table. Te column name is Total Sl (ie) To store the corresponding values in the Total Sal column. (0) Selet maxBasic) from Salary where Bonus > 4 (©) Selet count) from Employee group by Sex (oi). Selet Distinct Depa from Employee 14. With reference to following lations PERSONAL. andJOB answer the questions tat allow: Create flowing tbls such that Enpro and Sr are not nll and unique, dat of bith a 12 Jan 1960, names never lank, Are and Nati places vali, epi not empty, is between 4000 and 10000 ble : Personal Gao Name Dobirth _Nativeplace Hob 123 | Amit 23Jani965_| Delhi a7 | Mano) i2-dec1976_| Mumbai wa Abhi ii-augts7s | Allahabad 125 obapeiv77 | Delt 10-mari974 | Mumbai 2onise1 | Pune ms 25,en-2006 zadec2006 | 6000 19-24g.2007 apr 2004 Pore | 3-mar-2006 | 7500 | 13:mar2028 | sales ‘rame and salary of those who have Sports as hobby. fame of the eldest employee. trumber of employee area wise snow youngest employes fom each Native place 1 ow Sa, Nene, Hoby and Salary in descending order of Sry how the hobbies of those whose name pronounces 28 “AbhAY’ tppoinomen date and naive place of hose whose rae tat with Ao ends n't expense with suitable column heading of hose who shal ete alter 2ja2008 1 adionl bade onthe ompary incase slay of employes having oth 0 sports is increased by 10%. 9 Show the hobby of which ‘ere are 2 or more employees smn how many employee sal re today anima length of trie 29 Yur. rms caployer name and cate fbi who have served more hn 17 yea on ae (o) ew panes ofthowe who ear more than all ofthe employes of Sales dep Boe aig ofthe employens by 5 cf ni preset salary wit bby 8 Masco hey Mave complete atleast 3 years of service (Wate the output of (@ Select distinct hobby from personal (Select ava(elay) from personal (Age/Deli) {i Setet count distinct Native_plae) from personal {h) Sct nace, manasa) from Persona, Job where PersonaLEmpro «Joh S00 "(9 Add new tuple in the table Personal esenialy with hobby a» Musi | “Tae neve column email in Jb table "© Crate a able with aes of chun emp ame, and hoBy- 1 Cie view of Penal and Job deta of thew who hae ered the records of employes from Jb table whose hab Isnt Sports the table Personal. fob where PersalEmpno = JobSoo and Area in Jess than 15 years D 618 COMPUTER SCIENCE WITH PHN - 15. With reference tothe table below, answer the questions that follow ‘Table : Employees Empl Firstname Addeess «iy [ono | Ravi | Kumar | Ra agar ca 105 | ary | Wattor | Gandhi nagar | Gz8 1 | sam Tones | 33 Bim St Pais m5 | Swab | Ackerman [40US. 110 | Upton ae | Manila | Sengupn | 24 Finds sect | New Deli Robert | Samuel __| 9 Fifth Cross_| Washington 335 | Ri Tondon _| Shastri Nagar | _GZB 400 | Rachel | tee 121 Hanson St | New York | 441 Peter: Thompson | 11 Red Road Paris 7 32000 7500 “1 23000 Wit the SQL commands or the fileing wing abo ables ( To show firstname, lasmame, address and city ofall employees living in Pairs To dpe cto El en dacocing clr ef Pomme “To display the fsiname, lastname and total ilar of all manager from the ables f she loal lary lo tAladad Soy + aa ee ‘he maximum salary among managers and clerks from the table 619 & [groUrIvG RECORDS, JONS IN SAL salary forall departments with more than 3 people for a = ay te joe with maximum salary greater than or ea 6 300 i Hy ber of employes having “Manage” Job rma ot employees grouped by depino, (able EMPL) salaries grouped by department. (able EMPL) salary of employee grouped by their department number arts and Orders given in soloed problems. of customers’ orders grouped by custome (id) ae pm of al of order grouped by conc ad Se. Bah cate (Came nd he al emount ofl er orders em UPL De Slagrade The Ep ble as ley en ted carcass trade and Dept are being shown Below: auanvorede (Lowsal, Highsal, Grade) apt (Oeptno, DeptNane, Location) uetions 25 and 26 om the basi of hee tables: the department mares and the umber of heir employes ® [atte employee names and the name of their departrents

You might also like