Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
13 views6 pages

Class Xii SQL Practicals and Chapter 1 Eco

Piyush

Uploaded by

ayushk01776
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
13 views6 pages

Class Xii SQL Practicals and Chapter 1 Eco

Piyush

Uploaded by

ayushk01776
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 6
Q1.Consider the following Table:: Teacher . and write the SOL statements. (6) TEACHER 10 NAME DEPARTMENT | CATEGORY | GENDER SALARY 1 Tanya Social studies. | TCT F 25000 2 Sourabh Arts PRT M 20000 3 Nandita English PGT F 30000 4 James English ToT M 25000 5 Jaspreet Hindi PRT F 22000 6 Disha ‘Maths PRT F 21000 7 Sidharth Science TeT M 27000 8 Sonali ‘Maths TeT F 24500 6 Select Avg(salary)From Teacher Group By Gender, Ans.GENDER Avg(salary) M 24000 (20000+25000+27000/3=24000) F 24500 (25000+30000+22000+21000+24500/5=24500) 1.Display all the information about PGT Category Ans, SELECT * FROM TEACHER WHERE CATEGORY="PGT”; 2.To list the names of Female teachers of Hindi department, ‘Ans. SELECT NAME FROM TEACHER WHERE DEPARTMENT="Hindi” AND GENDER> 3.Count the number of Teachers in English department. SELECT COUNT(*) FROM TEACHER WHERE DEPARTMENT="English”; Write the output of the following commands:: 4 Select Distinct(category}from Teacher; Ans. CATEGORY PRT TcT PGT 5.Select count(") from teacher Where Category ="PGT"; Ans. 1 6 Select Avg(salary)From Teacher Group By Gender; ‘Ans. GENDER Avg(salary) ‘24000 (20000+25000+27000/3=24000) ™ F ‘24500 (25000+30000+22000+21000+24500/5=24500) Q2. Consider the table “Emp” 1D | NAME | AGE | ADDRESS] SALARY] PHONE T Sidharth |~ 34 Shaktingr | 40000 FAMA6344 2 Chavi 3 Gur mandi [67000 (6443578888 3 Karan B Pratap 34000 WTTTTSS4 bagh q Puneet 2 Vijayner [43000 FO66CAB33 3 Kunal 34 Kabirngr | 43700 WITTE Write a query to: Delete the Record having ID=3 uy} (ul) (vy) Edit the address of Puneet _as GTB nagar instead of vijay ngr. (III) Add recor n the table 6,” Vijay”, 34,” Gurmandi,30000,655677478 (IV) What is the degree and cardinality of this table Edit the Name of K ufial/as)kabi Q1. Consider the Table ‘Oven’ answer the following Mod No Articles Company 011 Mobile FB 012 Grill FB 013 LG Camera Ls 014 Fridge ‘Samsung 015) Grill LG 1. Which field can be set as Primary key and Why? 2. Write an SQL command o display unique company name from table Oven 3. What is the degree and cardinality of relation Oven. Q2Consider the table “Emp” 1D NAME AGE ADDRESS [SALARY _| PHONE 1 Sidharth [34 Shaktingr [40000 4440643344 2 Chavi 33 Gurmandi_| 67000 6443578888 3 Karan 43 Pratap bagh [54000 987777554 4 Puneet 22 Vijayngr__[ 43000 4666644333 5 Kunal 54 Kabirngr [43700 9999754333 Write the SQL commands : (i) Display the list of all employees below the age of 25 years old (ii) To list the names and salaries in descending order of salary. (iii) To list the name,age and address in ascending order of name. (iv) To count the number of employees with name starting with ‘K’ VL.WUIUIy, VEIIFUL 1U:L9U9UUL) Ql. You are given a Table :: Customer Customer ROLL_NO NAME AGE cry 2 ALKA 20 GHAZIABAD 2 bisa 2 VARANASI 6 PRATIK, 24 KANPUR Answer the following:: a) qi) ci (iv) (vy) (vi) (vii) What is the name of Table? There is another name of Table? What is it called as? How many fields are there in this Table What is another Name for column? What is the Degree of This table ? How many rows are there in this table? What is the Cardinality of this Table (vili) Which key can be assigned as Primary Key? Q2. Consider the table “Emp” 1D NAME AGE ‘ADDRESS: SALARY PHONE T Sidharth 3 ‘Shakti nar “40000 4444643344 z Chavi Er} Gur mandi 67000 64435788088 3 Karan a3 Pratap bagh | 54000 987777554 4 Puneet 22 Vijay nor “43000 4666644333, 5 Kunal 3 Kabir ngr 43700 9999754333, Write @ query to: (@) Delete the Record having ID=3 (I) Edit the address of Puneet as GTB nagar instead of vijay nar. (QI) Add record in the table 6,"Vijay”,34,"Gurmandi",30000,655677478, (IV) What is the degree and cardinality of this table (V)__ Edit the Name of Kunal as kabir ‘Ans, (i) DELETE from Emp WHERE It (i)UPDATE Emp SET Address ="GTB nagar” WHERE Name="Puneet”; (ii) INSERT INTO Emp VALUES(6,”Vijay”,34,"Gurmandi,30000,655677478); QL..write a query to create a table Travelagency. Agent code _char(4) primary key AgentName Varchar(20) Not Null Location varchar(25) Package varchar(30) Charges Decimal (b) Write a query to add new row to table TravelAgency (°A006","John” "Make my trip” "Domestic”,45000) Ans. CREATE table TravelAgency ( ‘Agent code char(4) primary key, ‘AgentName ——Varchar(20) Not Null, Location varchar(25), Package varchar(30), Charges Decimal y (b) INSERT INTO TravelAgency VALUES("A006","John” "Make my trip” "Domestic”,45000); QI,. Consider the following table Doctor and answer the following Queries in SQL 6) ID Department OPD_DAYS Doctor_Name Fee H201 ENT MWE Akash Arora 400 H308 Oncology TIS Dharma Sharma 600 907 Paediatrics © MWF Sanjay Singh 500 H896, ENT TTS Praveen Sethi 400 H675 Gynecology TTS Kavita Sharma 450 357 Haematology = MWF Dinesh Chaudhry 600 I. To display the name of all Doctors who visit OPD on ‘MWF’ Il. To display the all the details of Doctors whose Department ends with ‘y’ ‘IIL To count the Number of Doctors in ENT Department IV. To display names and the fee of doctors in the descending order of fee V. To add a new column Phone No to a table Doctor 1 To display the name of all Doctors who visit OPD on *MWF” Ans. SELECT Doctor_Name FROM Doctor WHERE OPD_DAYS ="MWF’; I. To display the all the details of Doctors whose Department ends with ‘y’ Ans. SELECT * FROM Doctor WHERE Department LIKE ‘%y’; "IIL, To count the Number of Doctors in ENT Department Ans. SELECT COUNT(*) FEOM Doctor WHERE Department="ENT’; IIL. To display names and the fee of doctors in the descending order of fee Ans.SELECT Doctor_Name,Fee FROM Doctor Order by Fee desc; IV. To add a new column Phone No to a table Doctor ALTER Table Doctor Add. Phone No int(10); Consider the following table ITEM and answer the following queries in SQL: Table : ITEM ICode IName Price Quantity tor Book 250 30 To2 Copy 30 1 103 Bag 270 30 104 Lunch Box 130 20 105 | Water Bottle 220 30 (i) To display the Item Name and Price of all items whose Quantity is more than 40. (ii) To add a new value in Table : ITEM 30. (iv) To display Item Name and Quantity in descending order of Price. (iii) To count the total number of items whose Quantity (v) To display all items whose Item Name starts with 8B’ Ans.(i)SELECT IName,Price FROM ITEM WHERE Quantity >40; (ii) INSERT INTO ITEM VALUES(106,”Pen”,20,100); (ili)SELECT Count(*) FROM ITEM WHERE Quantity =30; (iv)SELECT IName,Quantity FROM ITEM Order by Price Desc; (v)SELECT IName FROM ITEM WHERE IName LIKE ‘B’;

You might also like