w3resource
SQL exercises

SQL: Sort records using in operator

SQL Wildcard & Special Operator : Exercise-4 with Solution

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

Sample table: customer


Sample Solution:

SELECT * 
FROM customer 
WHERE customer_id IN (3007,3008,3009);

Output of the Query:

customer_id	cust_name	 city		grade	salesman_id
3007		Brad Davis	 New York	200		5001
3008		Julian Green   London		300		5002
3009		Geoff Cameron	Berlin		100		5003

Explanation:

Syntax of sort records using in operator

Pictorial presentation :

Result of sort records using in operator

Query Visualization:

Duration:

Query visualization of Sort records using in operator - Duration

Rows:

Query visualization of Sort records using in operator - Rows

Cost:

Query visualization of Sort records using in operator - Cost

 

Practice Online


Contribute your code and comments through Disqus.

Previous: Write a query to produce a list of salesman_id, name, city and commision of each salesman who live in cities other than Paris and Rome.
Next: Write a SQL statement to find those salesmen with all information who get the commission within a range of 0.12 and 0.14.

What is the difficulty level of this exercise?



New Content: Composer: Dependency manager for PHP, R Programming