w3resource

PostgreSQL Restricting and Sorting Data - Exercises, Practice, Solution

PostgreSQL Restricting and Sorting Data [11 exercises with solution]

1. Write a query to display the name, including first_name and last_name and salary for all employees whose salary is out of the range between $10,000 and $15,000.

Sample table: employees


Click me to see the solution

2. Write a query to display the name, including first_name and last_name, and department ID who works in the department 30 or 100 and arrange the result in ascending order according to the department ID.

Sample table: employees


Click me to see the solution

3. Write a query to display the name, including first_name and last_name, and salary who works in the department either 30 or 100 and salary is out of the range between $10,000 and $15,000.

Sample table: employees


Click me to see the solution

4. Write a query to display the name, including first_name and last_name and hire date for all employees who were hired in 1987.

Sample table: employees


Click me to see the solution

5. Write a query to get the first name of the employee who holds the letter 'c' and 'e' in the first name.

Sample table: employees


Sample table: departments


Click me to see the solution

6. Write a query to display the last name, job, and salary for all those employees who hasn't worked as a Programmer or a Shipping Clerk, and not drawing the salary $4,500, $10,000, or $15,000.

Sample table: employees


Click me to see the solution

7. Write a query to display the last names of employees whose name contain exactly six characters.

Sample table: employees


Click me to see the solution

8. Write a query to display the last name of employees having 'e' as the third character.

Sample table: employees


Click me to see the solution

9. Write a query to display the jobs/designations available in the employees table.

Sample table: employees


Click me to see the solution

10. Write a query to display the name, including first_name, last_name, salary and 15% of salary as PF of all employees.

Sample table: employees


Click me to see the solution

11. Write a query to select all information of employees whose last name is either 'JONES' or 'BLAKE' or 'SCOTT' or 'KING' or 'FORD'.

Sample table: employees


Click me to see the solution

 

... More

Structure of 'hr' database :

hr database


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/postgresql-exercises/restricting-and-sorting-data/