w3resource

SQL Exercise: Display the unique designations for the employees

SQL employee Database: Exercise-3 with Solution

[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:

SQL exercises on employee Database: Display the unique designations for the employees

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 Expression: Display the unique designations for the employees.

Relational Algebra Tree:

Relational Algebra Tree: Display the unique designations for the employees.

Practice Online


Sample Database: employee

employee database structure

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.



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://www.w3resource.com/sql-exercises/employee-database-exercise/sql-employee-database-exercise-3.php