w3resource

PostgreSQL Restricting and Sorting Data: Display the names, salary and PF of all employees


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

Sample Solution:

Code:

SELECT first_name, last_name, salary, salary*.15 PF 
FROM employees;

Sample table: employees


Output:

pg_exercises=# SELECT first_name, last_name, salary, salary*.15 PF
pg_exercises-# FROM employees;
 first_name  |  last_name  |  salary  |    pf
-------------+-------------+----------+-----------
 Steven      | King        | 24000.00 | 3600.0000
 Neena       | Kochhar     | 17000.00 | 2550.0000
 Lex         | De Haan     | 17000.00 | 2550.0000
 Alexander   | Hunold      |  9000.00 | 1350.0000
 Bruce       | Ernst       |  6000.00 |  900.0000
 David       | Austin      |  4800.00 |  720.0000
 ....
 Luis        | Popp        |  6900.00 | 1035.0000
 Den         | Raphaely    | 11000.00 | 1650.0000
 Alexander   | Khoo        |  3100.00 |  465.0000
 Shelli      | Baida       |  2900.00 |  435.0000
 Sigal       | Tobias      |  2800.00 |  420.0000
 Guy         | Himuro      |  2600.00 |  390.0000
 Karen       | Colmenares  |  2500.00 |  375.0000
 ....
 Steven      | Markle      |  2200.00 |  330.0000
 Laura       | Bissot      |  3300.00 |  495.0000
 Mozhe       | Atkinson    |  2800.00 |  420.0000
 James       | Marlow      |  2500.00 |  375.0000
 TJ          | Olson       |  2100.00 |  315.0000
 ....
 Renske      | Ladwig      |  3600.00 |  540.0000
 Stephen     | Stiles      |  3200.00 |  480.0000
 John        | Seo         |  2700.00 |  405.0000
 Joshua      | Patel       |  2500.00 |  375.0000
 Trenna      | Rajs        |  3500.00 |  525.0000
 ...
 Hermann     | Baer        | 10000.00 | 1500.0000
 Shelley     | Higgins     | 12000.00 | 1800.0000
 William     | Gietz       |  8300.00 | 1245.0000
 (107 rows)

Practice Online


Have another way to solve this solution? Contribute your code (and comments) through Disqus.

Previous: Write a query to display the jobs/designations available in the employees table.
Next: Write a query to select all information of employees whose last name is either 'JONES' or 'BLAKE' or 'SCOTT' or 'KING' or 'FORD'.

What is the difficulty level of this exercise?



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://w3resource.com/postgresql-exercises/restricting-and-sorting-data/restricting-and-sorting-data-exercise-10.php