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

CBSE Class 12 Computer Science SQL Questions

Class 12
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
349 views

CBSE Class 12 Computer Science SQL Questions

Class 12
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

CBSE Class 12 Computer Science SQL

Questions

CBSE Class 12 Computer Science SQL Questions 1


- Write SQL commands to create a table 'STUDENT' with
columns 'Roll_No', 'Name', and 'Marks'. Ensure 'Roll_No'
is the primary key.

Solution:

CREATE TABLE STUDENT ( Roll_No INT PRIMARY KEY, Name


VARCHAR(255) NOT NULL, Marks FLOAT NOT NULL );

CBSE Class 12 Computer Science SQL Questions 2


- Write a SQL query to display the names of students
who scored above 90 marks.

Solution:

SELECT StudentName FROM Students WHERE Marks > 90;

Check: CBSE Class 12 Computer Science Practical Viva


Questions

CBSE Class 12 Computer Science SQL Questions 3 - How


would you modify the table 'STUDENT' to add a new
column 'DOB' for the date of birth?

ALTER TABLE STUDENT ADD COLUMN DOB DATE;

CBSE Class 12 Computer Science SQL Questions 4


- Write a query to rename the table 'STUDENT' to
'SCHOLARS'.

ALTER TABLE STUDENT RENAME TO SCHOLARS;


CBSE Class 12 Computer Science SQL Questions 5 - How
would you delete all the records from the table
'SCHOLARS' where marks are below 40?

DELETE FROM SCHOLARS WHERE marks < 40;

Check: CBSE Class 12 Computer Science Books

CBSE Class 12 Computer Science SQL Questions 6


- Write an SQL query to count the number of students
who have marks between 50 and 70.

SELECT COUNT(*) FROM students WHERE marks BETWEEN 50


and 70;

CBSE Class 12 Computer Science SQL Questions 7 - How


can you retrieve unique marks from the 'SCHOLARS'
table?

Query: ALTER TABLE SCHOLARS RENAME TO STUDENT_MARKS;

CBSE Class 12 Computer Science SQL Questions 8


- Write a SQL statement to find the average marks of
students in the 'SCHOLARS' table.

RENAME TABLE SCHOLARS TO SCHOLAR_MARKS; SELECT


AVG(mark) FROM SCHOLAR_MARKS;

Check: CBSE Class 12 Computer Science Syllabus

CBSE Class 12 Computer Science SQL Questions 9 - How


would you retrieve the top 5 students based on marks?

SELECT TOP 5 * FROM Students ORDER BY Marks DESC;

Check: How to Prepare Computer Science for Judiciary


Exams?

CBSE Class 12 Computer Science SQL Questions 10


- Write a SQL command to update the marks of a
student with Roll_No = 10 to 95.
UPDATE student SET marks = 95 WHERE Roll_No = 10;

CBSE Class 12 Computer Science SQL Questions 11


- How can you remove the column 'DOB' from the
'SCHOLARS' table?

Use the SQL ALTER TABLE command to remove the 'DOB'


column from the 'SCHOLARS' table.

ALTER TABLE SCHOLARS DROP COLUMN DOB ;

CBSE Class 12 Computer Science SQL Questions 12


- Write an SQL statement to find the student with the
highest marks.

SELECT Max(marks) AS 'Highest Marks', name FROM students


GROUP BY name;

CBSE Class 12 Computer Science SQL Questions 13


- Create an index on the 'Name' column of the
'SCHOLARS' table.

ALTER TABLE SCHOLARS ADD INDEX (Name);

Check: CBSE 2023 Toppers Talk

CBSE Class 12 Computer Science SQL Questions 14


- Describe the difference between INNER JOIN and LEFT
JOIN with examples.

An INNER JOIN is a type of join that returns only the rows with
data in both the joined tables. It is the default join type of the
SQL query. For example, let's say we have two tables: Table1
and Table2. If we perform an INNER JOIN on these two tables
like this:

Select * from Table1


INNER JOIN Table2 on Table1.id = Table2.ID
It will only return the rows where the data in both tables
matches.

A LEFT JOIN on the other hand is a type of join that returns all
the data from the left table, even if there is no match in the
right table. For example, if we perform a LEFT JOIN like this:

Select * from Table1


LEFT JOIN Table2 on Table1.id= Table2.ID

It will return all the rows from Table1, regardless of whether


they have a match in Table2.

Check: Business Management Courses after 12th

CBSE Class 12 Computer Science SQL Questions 15


- Write a SQL query to find all students whose name
starts with the letter 'A'.

SELECT * FROM Students

WHERE name LIKE 'A%';

You might also like