SQL Exercise
Full student table with SQL Dump
Display all students whose ID are even numbers.
Display all students of Class Four in the order of mark from highest to lowest
Display all students of Class Four in the order of their Name
Display all students in the order of Class and then Mark.
Display all students who got mark more than 50
Display all students who got mark between 50 and 60
Display all students who’s name starts with A
Display all students who’s name ends with hn
Display all students who’s name has John at any location
Display all students who’s name start with A or start with B
Display all students who’s name ends with A or ends with B
Display all students who’s id is more than 10 and second digit is 3
Display all students who’s name starts with A and ends with n
Display all students who’s name starts with A but does not end with n
Display all details of the student having highest mark
Display the student having second highest mark
Display the 5 students who secured lowest mark
Display the students who’s name starts with A and got more than 60 mark
Display the students who’s ids are (within) 12, 14,13, 9 & 6
Display all the classes in student table
Display all 5 students who added recently ( last 5 records ) of student table
← Exercise on LIKE Queries
Find out the number of students.
Find out the number of students in Class Three
Find out the number of students who got more than 50 mark
Find out the number of students who got mark between 50 and 70
List the students who got more than 50 mark of class three
What is the highest mark
What is the highest mark of class Three
What is the average mark of class Four.
What is the minimum mark of class Five
What is the Total mark of students of class Three
List the full details of ( name, class, mark , sex ) of the student who got highest mark.
List details of students of top three rank holders based on mark.
UPDATE
Add 2 mark to each student
Add 5 mark to each student who got less than 50
Add -3 mark to each student who got more than 50
Change the last char for all the students ( name column ) by making it to y if it is x
DELETE
After deleting records to execute next query, create table by using the above SQL DUMP.
Delete all the records of Class file
Remove all the records who got mark less than 60
Remove all records who's name starts with Al
Remove all records who's name having John
Remove all records with odd number of ID
Remove all records not having John in its name
STRING
Display the student name and its number of Chars
Display the student name along with reverse of it
Display the student name along with name in Upper case
Display the first two chars of the student name
Display the last two chars of the student name
MORE on STRING
Check the String functions and use them here.
Use the SQL dump with sample emails
Display the rest of the email address starting from 3rd position from left.
Display the last four chars of the email address.
Display ( email address ) starting from 2nd position 4 chars (to be collected)
Display from right ( end ) starting from 6 position return 4 chars (length)
Display the position of @ inside email address along with the email address.
From the email address get the first (left) 3 chars along with the email address.
From the email address get the last (right) 3 chars along with the email address.
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 above concepts )
Using the above update, reverse the userid and display
Along with the original userid, display userid by adding plus2net_ before
Along with the original userid, display userid by adding plus2net_ after
Remove .com from the domain name
LINKING MORE THAN ONE TABLE
Use the SQL dump for football team and baseball team .
Hint Use Left Join
Exercise on LEFT JOIN
How many records will be returnd for this query SELECT * FROM student,student_football
How many records will be returnd for this query SELECT * FROM student,student_football,student_baseball
How many reocrds will be returned for this query SELECT * FROM student,student_football WHERE id=f_id
How many reocrds will be returned for this query SELECT * FROM student,student_football WHERE id != f_id
Display full details of students who are in NOT selected for football team ( use LEFT JOIN ) Try by not using LEFT Join and see the difference.
Display full details of students who are selected for football team
Display full details of students who are in baseball team
Display full details of students who are not there in football or baseball team
Display full details of students who are there in any one team
Use the SQL dump of Customer , Products and Sales data
List of products sold
List of quantity sold against each product.
List of quantity and total sales against each product
List of quantity sold against each product and against each store.
List of quantity sold against each Store with total turnover of the store.
List of products which are not sold
List of customers who have not purchased any product.
Use the SQL dump of Student, exam
Average mark of all students in all exams
Maximum mark of all students in all exams
Maximum mark of each month for all students
Average mark of each month for all students
Consider mark of student for the exams conducted in later part of the month.
← Exercise on DATE Queries
Exercise on LIKE Queries →
← What is SQL
SELECT Query to collect records →
This article is written by plus2net.com team.
Be the first to post comment:
plus2net.com
▼ More on getting records from table with different combinations of commands