MySQL Exercises with data and queries
csc-mysql-book-excercise-p08.md Student table with columns: id std_id Name marks From the image, the data looks approximately like this: id std_id Name marks 1 3 Abhi 98 2 5 Geethasi 89 3 6 Rahim 49 4 9 Ram 60 5 1 Rahul 87 6 1 Rahul 96 7 1 Rahul 96 8 9 Ram 96 9 9 Ram 96 1️⃣ Second Highest Marks SELECT MAX (marks) FROM student WHERE marks < ( SELECT MAX (marks) FROM student); 2️⃣ Find Duplicate Rows To find duplicate records based on all columns: SELECT id, std_id, name , marks, COUNT (*) FROM student GROUP BY id, std_id, name , marks HAVING COUNT (*) > 1; If checking duplicates by name and marks: SELECT name , marks, COUNT (*) FROM student GROUP BY name , marks HAVING COUNT (*) > 1; 3️⃣ Fetch First Record SELECT * FRO...