IT RDBMS Practical Ques
IT RDBMS Practical Ques
Solution:-
SELECT PrName FROM GYM;
PrName
Cross Trainer
Treadmill
Massage chair
Vibration Trainer
Bike
B) Display the names and unit price of all the products in the store
Solution:-
SELECT PrName, UnitPrice FROM GYM;
PrName UnitPrice
Cross Trainer 25000
Treadmill 32000
Massage chair 20000
Vibration Trainer 22000
Bike 13000
C) Display the names of all the products with unit price less than
Rs.20000.00
Solution:-
SELECT PrName FROM GYM WHERE UnitPrice < 20000;
PrName
Bike
D) Display details of all the products with unit price in the range
20000 to 30000
Solution:-
SELECT * FROM GYM WHERE UnitPrice BETWEEN 20000 AND 30000;
PrCode PrName UnitPrice Manufacturer
P101 Cross Trainer 25000 Avon Fitness
P103 Massage chair 20000 Fit Express
P104 Vibration Trainer 22000 Avon Fitness
1. Write a query to retrieve all the columns from a table named Students.
Solution:-
SELECT* FROM Students;
2. Write a query to find all students with a score greater than 75 from
the Students table.
Solution:-
8. Write a query to find classes that have an average score greater than
80.
Solution:-
SELECT class FROM Students GROUP BY class HAVING AVG(score) > 80;
Class
11A
11B
11C
9. Write a query to add a new student to the Students table with the
following details: student_id:10,Name: "John Doe", Age: 16, Class: "11A",
score:90.
Solution:-
INSERT INTO Students (student_id, name, age, class, score)
VALUES (10, 'John Doe', 16, '11A', 90);
Student_ID Name Age Class Score
1. John Doe 16 11A 85
2. Jane Smith 17 11B 90
3. Alice Brown 16 11A 78
4. Bob White 17 11C 88
5. Emma Wilson 15 11A 92
10. John Doe 16 11A 90
10. Write a query to update the score of a student named "Jane Smith" to
90 in the Students table.
Solution:-
UPDATE Students SET score = 90 WHERE name = 'Jane Smith';
Student_ID Name Age Class Score
1. John Doe 16 11A 85
2. Jane Smith 17 11B 90
3. Alice Brown 16 11A 78
4. Bob White 17 11C 88
5. Emma Wilson 15 11A 92
10. John Doe 16 11A 90
11. Write a query to remove a student record from the Students table
where the student ID is 10.
Solution:-
DELETE FROM Students WHERE student_id = 10;
Student_ID Name Age Class Score
1. John Doe 16 11A 85
2. Jane Smith 17 11B 90
3. Alice Brown 16 11A 78
4. Bob White 17 11C 88
5. Emma Wilson 15 11A 92
12. Write a query to find students whose scores are above the average
score of the class.
Solution:-
SELECT Name, Score
FROM Students
WHERE Score > (SELECT AVG(Score) FROM Students);
Name Score
Jane Smith 90
Bob White 88
Emma Wilson 92
13. Write a query to find all students who are in class "11A" and have a
score greater than 80.
Solution:-
SELECT Name, Score
FROM Students
WHERE Class = '11A' AND Score > 80;
Name Score
John Doe 85
Emma Wilson 92
____________________________________________________________