CBSE Computer Science - Revision Tour(Solved) CBSE Guess > eBooks > Class XII > CBSE Computer Science Structure Query Language Solved Revision Tour By Mr. Ravi Kiran COMPUTER SCIENCE STRUCTURED QUERY LANGUAGE 2002: 5. Given the following Teacher Relation. Write SQL Commands fro (b) to (g)
(b) To select all the information of teacher in computer department. Ans: Select * from Teacher where Department=”Computer” (c ) To list the name of female teachers in History Department. Ans: Select Name from Teacher Where Sex=”F” And Department=”History”. (d) To list all names of teachers with date of admission in ascending order. Ans: Select Name from Teacher Order By Dateofjoining Asc (e) To display Teacher's Name, Department, and Salary of female teachers Ans: Select Name,Department,Salary from Teacher Where Sex=”F” (f)To count the number of items whose salary is less than 10000 Ans: Select Count(*) from Teacher Where Salary<10000. (g) To insert a new record in the Teacher table with the following data: 8,”Mersha”,”Computer”,
(1/1/2000),12000,”M”.Ans: Insert into Teacher values ,”Mersha”, ”Computer”,{1/1/2000),12000,”M”); 2001: 5.b) Write the SQL commands for (i) to (vii) on the basis of the table SPORTS
(i) Display the names of the students who have grade ‘C’ in either Game1 or Game2 or both. Ans: Select Name From Sports Where Grade1=”C” OR Grade2=”C” (ii) Display the number of students getting grade ‘A’ in Cricket. Ans: Select Count(*) from Sports Where (Game1=”Cricket” and Grade1=”A”) or (Game2=”Cricket” and Grade2=”A”) (iii) Display the names of the students who have same game for both game1 and game2 Ans: Select Name From Sports Where Game1=Game2 (iv) Display the games taken up by the students, whose name starts with ‘A’. Ans: Select Game1,Game2 From Sports Where Name Like “A%” (v) Add a new column named ‘marks’. Ans: Alter Table Sports Add Marks Number(5); (vi) Assign a value 200 for marks for all those who are getting grade ‘B’ or ‘A’ in both Game1 and Game2. Ans: (Children, Try This Answer as an assignment) (vii) Arrange the whole table in the alphabetical order of name. Ans: Select * from Sports Order By Name
CBSE Computer Science Solved Revision Tour By Mr. Ravi Kiran ( [email protected] ) |
|