w3resource

PostgreSQL Basic Simple - Exercises, Practice, Solution

PostgreSQL Basic Simple [19 exercises with solution]

1. Write a query to display the names (first_name, last_name) using an alias name “First Name", "Last Name".

Sample table: employees


Click me to see the solution

2. Write a query to get a unique department ID from employee table.

Sample table: employees


Click me to see the solution

3. Write a query to get the details of all employees from the employee table in descending order by their first name.

Sample table: employees


Click me to see the solution

4. Write a query to get the names (first_name, last_name), salary and 15% of salary as PF for all the employees.

Sample table: employees


Click me to see the solution

5. Write a query to get the employee ID, names (first_name, last_name) and salary in ascending order according to their salary.

Sample table: employees


Sample table: departments


Click me to see the solution

6. Write a query to get the total salaries payable to employees.

Sample table: employees


Click me to see the solution

7. Write a query to get the maximum and minimum salary paid to the employees.

Sample table: employees


Click me to see the solution

8. Write a query to get the average salary and number of employees are working.

Sample table: employees


Click me to see the solution

9. Write a query to get the number of employees working with the company.

Sample table: employees


Click me to see the solution

10. Write a query to get the unique number of designations available in the employees table.

Sample table: employees


Click me to see the solution

11. Write a query to get all the first name from the employees table in upper case.

Sample table: employees


Click me to see the solution

12. Write a query to get the first three characters of the first name for all the employees in the employees table.

Sample table: employees


Click me to see the solution

13. Write a query to calculate the expression 171*214+625.

Click me to see the solution

14. Write a query to get the name, including first name and last name of all the employees from employees table.

Sample table: employees


Click me to see the solution

15. Write a query to get the first names after removing all the leading and trailing blanks of all the employees from employees table.

Sample table: employees


Click me to see the solution

16. Write a query to get the first name, last name and the length of the name, including first_name and last_name of all the employees from employees table.

Sample table: employees


Click me to see the solution

17. Write a query to check whether the first_name column of the employees table containing any number.

Sample table: employees


Click me to see the solution

18. Write a query to select first ten records from a table.

Sample table: employees


Click me to see the solution

19. Write a query to get a monthly salary (rounded up to 2 decimal places) of each employee.
Note : Assume the salary field provides the 'annual salary' information.

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/basic/