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
SELECT DISTINCT job_name FROM employees;
job_name ----------- CLERK SALESMAN MANAGER PRESIDENT ANALYST (5 rows)
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:
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.
SQL: Tips of the Day
Concatenate strings of a string field in a PostgreSQL 'group by' query:
ID COMPANY_ID EMPLOYEE 1 1 Anna 2 1 Bill 3 2 Carol 4 2 Dave
SELECT company_id, string_agg(employee, ', ') FROM mytable GROUP BY company_id;
COMPANY_ID EMPLOYEE 1 Anna, Bill 2 Carol, Dave
- Weekly Trends
- Python Interview Questions and Answers: Comprehensive Guide
- Scala Exercises, Practice, Solution
- Kotlin Exercises practice with solution
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join
We are closing our Disqus commenting system for some maintenanace issues. You may write to us at reach[at]yahoo[dot]com or visit us at Facebook