0% found this document useful (0 votes)
35 views

Pooja WS2

This document contains SQL queries and commands related to a student database table. It includes commands to: 1. Create a student table with fields like admission number, name, class, section, average. 2. Insert values into the student table for 6 students. 3. Write 18 SQL queries to select data from the student table based on various conditions on fields like name, class, section, average. The conditions include equality, inequality, BETWEEN, LIKE, OR etc.

Uploaded by

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

Pooja WS2

This document contains SQL queries and commands related to a student database table. It includes commands to: 1. Create a student table with fields like admission number, name, class, section, average. 2. Insert values into the student table for 6 students. 3. Write 18 SQL queries to select data from the student table based on various conditions on fields like name, class, section, average. The conditions include equality, inequality, BETWEEN, LIKE, OR etc.

Uploaded by

kanha dd
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Classification: Internal

CBSE
COMPUTER SCIENCE GRADE 12
WORKSHEET 2(SQL)
Name: Pooja Date:
Q1. Given the following table:
Table: STUDENT
AdNo Name Class Section Average
ID111 Anu 11 A 95
ID121 Balu 12 D 90
ID71 Leena 7 C 65
ID105 Madhu 10 B 75
ID75 Surpreeth 7 C 80
ID69 Beena 6 A 70
Write commands for the following:
a) To create the table Student.
create table student(
AdNo char(10),
Name CHAR(20),
Class integer,
Section CHAR(1),
Average integer
);

b) To insert values in each row.

insert into student values


('ID111','Anu',11,'A',95);

insert into student values


('ID121','Balu',12,'D',90);

insert into student values


('ID71','Leena',7,'C',65);

insert into student values


('ID105','Madhu',10,'B',75);

insert into student values


('ID75','Supreeth',7,'C',80);

insert into student values


('ID69','Beena',6,'A',70);

Q2. Write SQL commands for the following:


Classification: Internal

1. Display details of all students.

2. Display name and class of all students.

Select nAME,CLASS FROM STUDENT;

3. Display name and average of those students having less than 80.

Select Name,average from student where average<80;

4. Display unique classes.

Select disTINCT class from student;


Classification: Internal

5. Display all admission numbers.

Select all AdNo from student;

6. Display details of the student with admission number ID75 or ID121.

Select * FROM student where AdNo='ID75' OR AdNo='ID121';

7. Display details of the student with admission number ID111 or studying in class 12.

Select * FROM STUDENT WHERE ADNo='ID111' OR CLASS=12;


Classification: Internal

8. Display details of students studying in class 6 or 8 or 10.

Select * FROM STUDENT WHERE CLASS=6 OR CLASS=8 OR CLASS=10;

9. Display name and admission no of students studying in section 'A' or 'D'.

Select * FROM STUDENT WHERE SECTION='A' OR SECTION='D';

10. Display details of students of Grade 12 having average more than 80.

Select * FROM STUDENT WHERE CLASS=12 AND AVERAGE>80;


Classification: Internal

11. Display names of students not studying in section 'D';

Select * FROM STUDENT WHERE SECTION!='D';

12. Display details of students whose average is between 65 and 85.

Select * FROM STUDENT WHERE AVERAGE BETWEEN 65 AND 85;

13. Display details of students whose Name begins with the character ‘B’.

Select * FROM STUDENT WHERE NAME LIKE 'B%';

14. Display all names having exactly 5 characters.


Classification: Internal

Select * FROM STUDENT WHERE NAME LIKE '_____';

15. Display all names having the character ‘a’.

Select * FROM STUDENT WHERE NAME LIKE '%a%';

16. Display all names ending with ‘u’.

Select * FROM STUDENT WHERE NAME LIKE '%u';

17. Display all names having the 2nd character as ‘a’.

Select * FROM STUDENT WHERE NAME LIKE '_a%';


Classification: Internal

18. Display all names having the 2nd character as ‘e’ and last character as ‘a’.

Select * FROM STUDENT WHERE NAME LIKE '_e%a';

You might also like