PostgreSQL Basic SELECT Statement: Get unique department ID from employee table
2. Write a query to get a unique department ID from employee table.
SELECT DISTINCT department_id FROM employees;
Sample table: employees
pg_exercises=# SELECT DISTINCT department_id pg_exercises-# FROM employees; department_id --------------- 90 20 100 40 110 80 70 50 60 30 10 0 (12 rows)
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous: Write a query to display the names (first_name, last_name) using an alias name "First Name", "Last Name".
Next: Write a query to get the details of all employees from the employee table in descending order by their first name.
What is the difficulty level of this exercise?
- New Content published on w3resource :
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework