w3resource logo
SQL exercises

SQL Exercises, Practice, Solution - Wildcard and Special operators

SQL [22 exercises with solution]

1. Write a SQL statement to find those salesmen with all information who come from the city either Paris or Rome.  Go to the editor

Sample table: salesman


Click me to see the solution with pictorial presentation

2. Write a query to filter those salesmen with all information who comes from any of the cities Paris and Rome.  Go to the editor

Sample table: salesman


Click me to see the solution with pictorial presentation

3. Write a query to filter those salesmen with all information who likes to leave other cities than Paris and Rome.   Go to the editor

Sample table: salesman


Click me to see the solution with pictorial presentation

4. Write a query to sort out those customers with all information whose ID value is within any of 3007, 3008 and 3009.   Go to the editor

Sample table: customer


Click me to see the solution with pictorial presentation

5. Write a SQL statement to find those salesmen with all information who gets the commission within a range of 0.12 and 0.14.   Go to the editor

Sample table: salesman


Click me to see the solution with pictorial presentation

6. Write a query to filter all those orders with all information which purchase amount value is within the range 500 and 4000 except those orders of purchase amount value 948.50 and 1983.43.   Go to the editor

Sample table: orders


Click me to see the solution with pictorial presentation

7. Write a SQL statement to find those salesmen with all other information and name started with any latter within 'A' and 'K'.  Go to the editor

Sample table: salesman


Click me to see the solution with pictorial presentation

8. Write a SQL statement to find those salesmen with all other information and name started with other than any latter within 'A' and 'L'.   Go to the editor

Sample table: salesman


Click me to see the solution with pictorial presentation

9. Write a SQL statement to find that customer with all information whose name begin with the letter 'B'.  Go to the editor

Sample table: customer


Click me to see the solution with pictorial presentation

10. Write a SQL statement to find all those customers with all information whose names are ending with the letter 'n'.  Go to the editor

Sample table: customer


Click me to see the solution with pictorial presentation

11. Write a SQL statement to find those salesmen with all information whose name containing the 1st character is 'N' and the 4th character is 'l' and rests may be any character.  Go to the editor

Sample table : salesman


Click me to see the solution with pictorial presentation

12. Write a SQL statement to find those rows from the table testtable which contain the escape character underscore ( _ ) in its column 'col1'.  Go to the editor

Sample table: testtable


Click me to see the solution with pictorial presentation

13. Write a SQL statement to find those rows from the table testtable which does not contain the character underscore ( _ ) in its column 'col1'.  Go to the editor

Sample table: testtable


Click me to see the solution with pictorial presentation

14. Write a SQL statement to find those rows from the table testtable which contain the escape character ( / ) in its column 'col1'.  Go to the editor

Sample table: testtable


Click me to see the solution with pictorial presentation

15. Write a SQL statement to find those rows from the table testtable which does not contain the escape character ( / ) in its column 'col1'.  Go to the editor

Sample table: testtable


Click me to see the solution with pictorial presentation

16. Write a SQL statement to find those rows from the table testtable which contain the string ( _/ ) in its column 'col1'.  Go to the editor

Sample table: testtable


Click me to see the solution with pictorial presentation

17. Write a SQL statement to find those rows from the table testtable which does not contain the string ( _/ ) in its column 'col1'.  Go to the editor

Sample table: testtable


Click me to see the solution with pictorial presentation

18. Write a SQL statement to find those rows from the table testtable which contain the character ( % ) in its column 'col1'.  Go to the editor

Sample table: testtable

Click me to see the solution with pictorial presentation

19. Write a SQL statement to find those rows from the table testtable which does not contain the character ( % ) in its column 'col1'.  Go to the editor

Sample table: testtable


Click me to see the solution with pictorial presentation

20. Write a SQL statement to find that customer with all information who does not get any grade except NULL.  Go to the editor

Sample table: customer

Click me to see the solution with pictorial presentation

21. Write a SQL statement to find that customer with all information who gets a grade except NULL value.  Go to the editor

Sample table: customer


Click me to see the solution with pictorial presentation

22. Write a query in SQL to display all the data of employees whose last name begins with an 'D'. 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.