w3resource

PostgreSQL Basic SELECT Statement: Display name, salary and 15% of salary as PF for all employees


4. Write a query to get the names (first_name, last_name), salary and 15% of salary as PF for all the 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
 ....
 Jose Manuel | Urman       |  7800.00 | 1170.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
 ....
 Julia       | Nayer       |  3200.00 |  480.0000
 Irene       | Mikkilineni |  2700.00 |  405.0000
 James       | Landry      |  2400.00 |  360.0000
 Steven      | Markle      |  2200.00 |  330.0000
 ....
 Jason       | Mallin      |  3300.00 |  495.0000
 Michael     | Rogers      |  2900.00 |  435.0000
 Ki          | Gee         |  2400.00 |  360.0000
 Hazel       | Philtanker  |  2200.00 |  330.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
 ....

Practice Online



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

What is the difficulty level of this exercise?



New Content: Composer: Dependency manager for PHP, R Programming