This document contains a student data table with columns like name, stipend, stream, average, grade, and class. It then lists various SQL queries to retrieve, update, and analyze data from this student table. It also describes two tables for a school database - School and Admin tables, and lists SQL queries on these tables related to retrieving teacher details, subjects, and analyzing aggregate data. Finally, it asks to define some database concepts and differentiate between SQL clauses, functions and keys.
Download as DOCX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
15 views
SQL Revision 2021 (CS)
This document contains a student data table with columns like name, stipend, stream, average, grade, and class. It then lists various SQL queries to retrieve, update, and analyze data from this student table. It also describes two tables for a school database - School and Admin tables, and lists SQL queries on these tables related to retrieving teacher details, subjects, and analyzing aggregate data. Finally, it asks to define some database concepts and differentiate between SQL clauses, functions and keys.
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3
Hari om
Chinmaya Vidyalaya Sr. Sec. School, virugambakkam, Ch-92.
Class: XII Computer Science- Revision Worksheet Topic: SQL Table Name: Student No. Name Stipend Stream Avg Grade Class 1 Karan 400.00 Medical 78.5 B 12B 2 Divakar 450.00 Commerce 89.2 A 11C 3 Divya 300.00 Commerce 68.6 C 12C 4 Arun 350.00 Humanities 73.1 B 12C 5 Sabina 500.00 Nonmedical 90.6 A 11A 6 John 400.00 Medical 75.4 B 12B 7 Robert 250.00 Humanities 64.4 C 11A 8 Rubina 450.00 Nonmedical 88.5 A 12A 9 Vikas 500.00 Nonmedical 92.0 A 12A 10 Mohan 300.00 Commerce 67.5 C 12C
Write SQL query for the following statements.
1. Write a command to create the above table.
2. Which column is suitable to be a primary key attribute? 3. What is the degree and cardinality of table student? 4. Display the details of student in ascending order of name. 5. Write query to change the grade of karan from ‘B’ to ‘A’ 6. Display the average of Grade ‘A’ students. 7. Display the average stipend amount of Medical Stream. 8. Display the details of class 12A students. 9. Display the number of students in each class. 10. Display the Medical students in class 12. 11.Display the sum of average marks of Commerce students. 12.Display the number of students in each grade whose average is above 80 13. Remove the Nonmedical students from the table. 14.Display how many students names are ending with ‘a’. 15.Display the names and class of students in Humanities and Commerce stream. 2. Consider the following two tables and answer the questions given below.
a. To decrease period by 10% of the teachers of English subject.
b. To display TEACHERNAME, CODE and DESIGNATION from tables SCHOOL and ADMIN whose gender is male c. To Display number of teachers in each subject. d. To display details of all teachers who have joined the school after 01/01/1999 in descending order of experience. e. Delete all the entries of those teachers whose experience is less than 10 years and name contains the substring ‘IS’ in SCHOOL table. f. Display the name of the teacher who is joined recently. g. Display the minimum experience in Physics subject. h. Display the number of Female teachers . i. Display the Designation which has minimum 2 teachers. j. Display all the details of HOD. k. Display the designations of English subject. l. Display the Designation wise total experience. m. To list the names of all teachers with their date of joining in descending order. n. To display number of male and female teachers in Coordinator Designation. o. Display the teacher details who are joined in the year 2000. p. Write the OUTPUT of the following command. SELECT TEACHER NAME, PERIODS, DESIGNATION FROM SCHOOL, ADMIN where school.code=Admin.code and periods between 27 and 30; q. SELECT AVG(PERIODS),DESIGNATION from School, Admin where School.code=Admin.code group by Designation; r. SELECT MAX(DOJ),MIN(DOJ) from School; s. SELECT MIN(EXP) from School where SUBJECT=’ENGLISH’ OR SUBJECT=’MATHS’; t. SELECT DESIGNATION, GENDER,COUNT(*) from Admin where DESIGNATION=’HOD’ group by Gender; u. Write a command to open the table Admin. v. Write a command to display the structure of the table School. w. Identify the primary Key of School table. x. To display the tables in Exam database. y. SELECT COUNT(SUBJECT), DISTINCT SUBJECT from School. z. SELECT TEACHERNAME from School,Admin where School.Code=Admin.Code and Designation=’Senior Teacher’ and TeacherName like’_a%’;
3. Answer the following questions.
(i) Write the difference between having and where clause. (ii) Write the difference between multi row and single row functions with an example. (iii) Differentiate Primary key and Unique (iv) DDL and DML, Delete and Drop, Alter and Update. Define: Primary Key, Candidate Key, Alternate Key, Foreign Key. Define: Degree, Cardinality, Tuple, Attribute, domain, RDBMS, MySql.