0% found this document useful (0 votes)
2 views3 pages

SQL Practical Lab File

The document contains a practical lab file with 15 SQL questions and their corresponding queries. It covers creating and manipulating a 'Student' table and a 'Course' table, including operations like inserting, updating, deleting records, and retrieving data based on specific conditions. Additionally, it includes aggregate functions to analyze student marks and course information.

Uploaded by

homev71661
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)
2 views3 pages

SQL Practical Lab File

The document contains a practical lab file with 15 SQL questions and their corresponding queries. It covers creating and manipulating a 'Student' table and a 'Course' table, including operations like inserting, updating, deleting records, and retrieving data based on specific conditions. Additionally, it includes aggregate functions to analyze student marks and course information.

Uploaded by

homev71661
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/ 3

SQL Practical Lab File (15 Questions with Answers)

1. Create a table named 'Student' with Roll_No, Name, Course, and Marks.

SQL Query:

CREATE TABLE Student (

Roll_No INT PRIMARY KEY,

Name VARCHAR(50),

Course VARCHAR(30),

Marks INT

);

2. Insert records into the 'Student' table.

SQL Query:

INSERT INTO Student (Roll_No, Name, Course, Marks) VALUES (1, 'Aman', 'BCA', 85);

INSERT INTO Student (Roll_No, Name, Course, Marks) VALUES (2, 'Neha', 'BCA', 90);

INSERT INTO Student (Roll_No, Name, Course, Marks) VALUES (3, 'Rahul', 'BBA', 78);

INSERT INTO Student (Roll_No, Name, Course, Marks) VALUES (4, 'Priya', 'BCA', 88);

INSERT INTO Student (Roll_No, Name, Course, Marks) VALUES (5, 'Sahil', 'BBA', 82);

3. Display all records from 'Student' table.

SQL Query:

SELECT * FROM Student;

4. Display students having marks greater than 80.

SQL Query:

SELECT * FROM Student WHERE Marks > 80;


5. Update marks of student whose Roll_No is 3.

SQL Query:

UPDATE Student SET Marks = 85 WHERE Roll_No = 3;

6. Delete record of student whose Name is 'Sahil'.

SQL Query:

DELETE FROM Student WHERE Name = 'Sahil';

7. Display students in ascending order of Marks.

SQL Query:

SELECT * FROM Student ORDER BY Marks ASC;

8. Count total number of students.

SQL Query:

SELECT COUNT(*) AS Total_Students FROM Student;

9. Find maximum and minimum marks.

SQL Query:

SELECT MAX(Marks) AS Highest_Marks, MIN(Marks) AS Lowest_Marks FROM Student;

10. Display average marks of students.

SQL Query:

SELECT AVG(Marks) AS Average_Marks FROM Student;

11. Display sum of marks of all students.


SQL Query:

SELECT SUM(Marks) AS Total_Marks FROM Student;

12. Create a table named 'Course'.

SQL Query:

CREATE TABLE Course (

Course_ID INT PRIMARY KEY,

Course_Name VARCHAR(30),

Duration VARCHAR(10)

);

13. Insert records into 'Course' table.

SQL Query:

INSERT INTO Course (Course_ID, Course_Name, Duration) VALUES (101, 'BCA', '3 Years');

INSERT INTO Course (Course_ID, Course_Name, Duration) VALUES (102, 'BBA', '3 Years');

INSERT INTO Course (Course_ID, Course_Name, Duration) VALUES (103, 'MBA', '2 Years');

14. Display all records from 'Course' table.

SQL Query:

SELECT * FROM Course;

15. Display students enrolled in 'BCA' course.

SQL Query:

SELECT * FROM Student WHERE Course = 'BCA';

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy