w3resource logo
SQL exercises

SQL Exercises, Practice, Solution - Using Boolean and Relational operators

SQL [12 exercises with solution]

1. Write a query to display all customers with a grade above 100.  Go to the editor

Sample table: customer


Click me to see the solution with pictorial presentation

2. Write a query statement to display all customers in New York who have a grade value above 100.   Go to the editor

Sample table: customer


Click me to see the solution with pictorial presentation

3. Write a SQL statement to display all customers, who are either belongs to the city New York or had a grade above 100.   Go to the editor

Sample table: customer


Click me to see the solution with pictorial presentation

4. Write a SQL statement to display all the customers, who are either belongs to the city New York or not had a grade above 100.   Go to the editor

Sample table: customer


Click me to see the solution with pictorial presentation

5.Write a SQL query to display those customers who are neither belongs to the city New York nor grade value is more than 100.   Go to the editor

Sample table: customer


Click me to see the solution with pictorial presentation

6. Write a SQL statement to display either those orders which are not issued on date 2012-09-10 and issued by the salesman whose ID is 505 and below or those orders which purchase amount is 1000.00 and below.   Go to the editor

Sample table : orders


Click me to see the solution with pictorial presentation

7.Write a SQL statement to display salesman_id, name, city and commission who gets the commission within the range more than 0.10% and less than 0.12%.  Go to the editor

Sample table : salesman


Click me to see the solution with pictorial presentation

8. Write a SQL query to display all orders where purchase amount less than 200 or exclude those orders which order date is on or greater than 10th Feb,2012 and customer id is below 3009. Go to the editor

Sample table : orders


Click me to see the solution with pictorial presentation

9. Display all in reverse, where order dates equal to a specified date or customer id greater than a specified number and purchase amount less than a specified amount.  Go to the editor

Sample table : orders


Click me to see the solution with pictorial presentation

10. Write a SQL query to display order number, purchase amount, archived, the unachieved percentage for those order which exceeds the 50% of the target value of 6000.   Go to the editor

Sample table: orders


Click me to see the solution with pictorial presentation

11. Write a query in SQL to find the data of employees whose last name is Dosni or Mardy.   Go to the editor

Sample table : emp_details


Click me to see the solution with result

12. Write a query in SQL to display all the data of employees that work in department 47 or department 63.   Go to the editor

Sample table : emp_details


Click me to see the solution with result

Practice Online


More to Come !

Do not submit any solution of the above exercises at here, if you want to contribute go to the appropriate exercise page.