SQL Exercise: Display the unique designations for the employees
[An editor is available at the bottom of the page to write and execute the scripts.]
3. From the following table, write a SQL query to find the unique designations of the employees. Return job name.
Sample table: employees
Pictorial Presentation:
Sample Solution:
SELECT DISTINCT job_name
FROM employees;
Sample Output:
job_name ----------- CLERK SALESMAN MANAGER PRESIDENT ANALYST (5 rows)
Explanation:
The said query in SQL that retrieves all distinct (unique) values in the "job_name" column of the 'employees' table .
The DISTINCT keyword eliminates duplicate values from the result set, so this query will only return a list of unique job names that are stored in the 'employees' table.
Relational Algebra Expression:
Relational Algebra Tree:
Practice Online
Sample Database: employee
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous SQL Exercise: Find the salaries of all employees.
Next SQL Exercise: Employee names and salaries are increased by 15% in $.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics