﻿ SQL Exercises - Using Boolean operators - w3resource

# 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 5005 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. Write a SQL statement to exclude the rows which satisfy 1) order dates are 2012-08-17 and purchase amount is below 1000 2) customer id is greater than 3005 and purchase amount is below 1000.  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, achieved, 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 !

Query visualizations are generated using Postgres Explain Visualizer (pev).

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

﻿