SQL Question Paper
Sample Table: Students
ID Name Age City Marks
1 Arun 20 Chennai 78
2 Bala 22 Madurai 85
3 Divya 21 Chennai 92
4 Kiran 23 Trichy 67
5 Mano 20 Madurai 74
1. Create a database named CollegeDB.
2. Display all databases.
3. Create a database named StudentDB.
4. Display the current database.
5. Drop the database OldDB.
6. Use the database StudentDB.
7. Create a table Students with columns ID, Name, Age.
8. List all tables in the current database.
9. Add a column City to the Students table.
10. Add two columns Marks and Department to the Students table.
11. Modify the datatype of Marks.
12. Change the column name Name to StudentName.
13. Add a column at a specific position in the table.
14. Rename the table Students to Student_Details.
15. Insert one record into the table.
16. Insert multiple records into the table.
17. Update the age of a student whose ID is 3.
18. Update marks for all students.
19. Delete a student whose ID is 5.
20. Delete multiple students whose age is greater than 22.
21. Display students whose age is greater than 21.
22. Display students whose marks are less than 80.
23. Display students whose age is greater than 20 and marks greater than 75.
24. Display students whose city is Chennai or Madurai.
25. Display students whose city is not Trichy.
26. Display students whose city is in Chennai or Madurai.
27. Display students whose city is not in Trichy.
28. Display students whose marks are between 70 and 90.
29. Display students whose age is between 20 and 22.
30. Display students whose name starts with the letter A.
31. Display students whose name ends with the letter a.
32. Display students whose name contains the letter i.
33. Display students ordered by marks in ascending order.
34. Display students ordered by marks in descending order.
35. Display students ordered by age and marks.
36. Display the first 3 students.
37. Display 2 students starting from the 2nd record.
38. Find the total number of students.
39. Find the sum of marks of all students.
40. Find the average marks of students.
41. Find the minimum marks.
42. Find the maximum marks.
43. Display the average marks rounded to 2 decimal places.
44. Display the number of students in each city.
45. Display the average marks for each city.
46. Display the maximum marks in each city.
47. Display the minimum marks in each city.
48. Display the total marks for each city.
49. Display cities having more than one student.
50. Display cities where average marks are greater than 75.