w3resource logo


SQL exercises

SQL Exercises, Practice, Solution - Retrieve data from tables

Secondary Nav

SQL [11 exercises with solution]

1. Write a SQL statement to display all the information of all salesmen.  Go to the editor

Sample table : salesman

Click me to see the solution with pictorial presentation

2. Write a SQL statement to display a string "This is SQL Exercise, Practice and Solution".  Go to the editor
Click me to see the solution with pictorial presentation

3. Write a query to display three numbers in three columns.  Go to the editor
Click me to see the solution with pictorial presentation

4. Write a query to display the sum of two numbers 10 and 15 from RDMS sever.  Go to the editor
Click me to see the solution with pictorial presentation

5. Write a query to display the result of an arithmetic expression.  Go to the editor
Click me to see the solution with pictorial presentation

6. Write a SQL statement to display specific columns like name and commission for all the salesmen.   Go to the editor
Sample table : salesman

Click me to see the solution with pictorial presentation

7. Write a query to display the columns in a specific order like order date, salesman id, order number and purchase amount from for all the orders.   Go to the editor
Sample table : orders

Click me to see the solution with pictorial presentation

8. Write a query which will retrieve the value of salesman id of all salesmen, getting orders from the customers in orders table without any repeats.  Go to the editor

Sample table : orders

Click me to see the solution with pictorial presentation

9. Write a SQL statement to display names and city of salesman, who belongs to the city of Paris.  Go to the editor

Sample table : salesman

Click me to see the solution with pictorial presentation

10. Write a SQL statement to display all the information for those customers with a grade of 200.   Go to the editor

Sample table : customer

Click me to see the solution with pictorial presentation

11. Write a SQL query to display the order number followed by order date and the purchase amount for each order which will be delivered by the salesman who is holding the ID 5001.   Go to the editor

Sample table: orders


Click me to see the solution with pictorial presentation

Practice Online




Join our Question Answer community to learn and share your programming knowledge.