SQL: Select distinct values from a table
SQL Basic Select Statement : Exercise-8 with Solution.
Write a query which will retrieve the values of salesman id of all salesmen getting orders from the customers in orders table without any repeats.
Sample table: orders
Sample Solution :
SELECT DISTINCT salesman_id FROM orders;
Output of the Query:
salesman_id 5002 5003 5006 5001 5005 5007
Pictorial presentation :
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous: Write a query to display salesman_id, salesman name, order date, order no, and purchase amount from orders table.
Next: Write a query to display names and city of salesman, who belongs to the city of Paris.
What is the difficulty level of this exercise?