SQL Exercise



  1. Display all students whose ID are even numbers.
  2. Display all students of Class Four in the order of mark from highest to lowest
  3. Display all students of Class Four in the order of their Name
  4. Display all students in the order of Class and then Mark.
  5. Display all students who got mark more than 50
  6. Display all students who got mark between 50 and 60
  7. Display all students who’s name starts with A
  8. Display all students who’s name ends with hn
  9. Display all students who’s name has John at any location
  10. Display all students who’s name start with A or start with B
  11. Display all students who’s name ends with A or ends with B
  12. Display all students who’s id is more than 10 and second digit is 3
  13. Display all students who’s name starts with A and ends with n
  14. Display all students who’s name starts with A but does not end with n
  15. Display the student having highest mark
  16. Display the student having second highest mark
  17. Display the 5 students who secured lowest mark
  18. Display the students who’s name starts with A and got more than 60 mark
  19. Display the students who’s ids are 12, 14,13, 9 & 6
  20. Display all the classes in student table
UPDATE
  1. Add 2 mark to each student
  2. Add 5 mark to each student who got less than 50
  3. Add -3 mark to each student who got more than 50
  4. Change the last char for all the students by making it to y if it is x
  5. In one column email address are stored, create another two columns and store userid in one and domain part in other column of the table.
Use the SQL dump for football team and baseball team.
Hint Use Left Join
  1. Display full details of students who are in NOT selected for football team ( use LEFT JOIN )

    SELECT id,name,class,mark,sex,f_id FROM `student`
    LEFT JOIN student_football on id=f_id
    WHERE f_id IS NULL
  2. Display full details of students who are selected for football team

    SELECT id,name,class,mark,sex,f_id FROM `student`
    LEFT JOIN student_football on id=f_id
    WHERE f_id is not null
  3. Display full details of students who are in baseball team

    SELECT id, name, class, mark, sex, b_id FROM `student` LEFT JOIN student_baseball ON id = b_id WHERE b_id IS NOT NULL
  4. Display full details of students who are not there in football or baseball team
    SELECT id,name,class,mark,sex,b_id,f_id FROM `student`
    LEFT JOIN student_baseball on id=b_id
    LEFT JOIN student_football on id=f_id
    WHERE b_id is null and f_id is null
  5. Display full details of students who are there in any one team
    SELECT id,name,class,mark,sex,b_id,f_id FROM `student`
    LEFT JOIN student_baseball on id=b_id
    LEFT JOIN student_football on id=f_id
    WHERE b_id is not null or f_id is not null


plus2net.com



Post your comments , suggestion , error , requirements etc here .
















We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
©2000-2020 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer