w3resource

Oracle: Query to list first name, last name and their salary for employee

Oracle Basic: Exercise-1 with Solution

Write a query to list first name, last name and their salary for employee contained in the employees table.

Note: To specify multiple columns in a SELECT list, you separate the column names with commas. For good practice insert a space after each comma for readability.

Sample table: employees


Sample Solution:

Oracle Code :

SELECT first_name, last_name, salary 
from employees;

Output:

SQL> SELECT first_name, last_name, salary
  2  From employees;

FIRST_NAME           LAST_NAME                     SALARY
-------------------- ------------------------- ----------
Steven               King                           24000
Neena                Kochhar                        17000
Lex                  De Haan                        17000
Alexander            Hunold                          9000
Bruce                Ernst                           6000
David                Austin                          4800
Valli                Pataballa                       4800
Diana                Lorentz                         4200
Nancy                Greenberg                      12008
Daniel               Faviet                          9000
John                 Chen                            8200

FIRST_NAME           LAST_NAME                     SALARY
-------------------- ------------------------- ----------
Ismael               Sciarra                         7700
Jose Manuel          Urman                           7800
Luis                 Popp                            6900
Den                  Raphaely                       11000
Alexander            Khoo                            3100
Shelli               Baida                           2900
Sigal                Tobias                          2800
Guy                  Himuro                          2600
Karen                Colmenares                      2500
Matthew              Weiss                           8000
Adam                 Fripp                           8200

FIRST_NAME           LAST_NAME                     SALARY
-------------------- ------------------------- ----------
Payam                Kaufling                        7900
Shanta               Vollman                         6500
Kevin                Mourgos                         5800
Julia                Nayer                           3200
Irene                Mikkilineni                     2700
James                Landry                          2400
Steven               Markle                          2200
Laura                Bissot                          3300
Mozhe                Atkinson                        2800
James                Marlow                          2500
TJ                   Olson                           2100

FIRST_NAME           LAST_NAME                     SALARY
-------------------- ------------------------- ----------
Jason                Mallin                          3300
Michael              Rogers                          2900
Ki                   Gee                             2400
Hazel                Philtanker                      2200
Renske               Ladwig                          3600
Stephen              Stiles                          3200
John                 Seo                             2700
Joshua               Patel                           2500
Trenna               Rajs                            3500
Curtis               Davies                          3100
Randall              Matos                           2600

FIRST_NAME           LAST_NAME                     SALARY
-------------------- ------------------------- ----------
Peter                Vargas                          2500
John                 Russell                        14000
Karen                Partners                       13500
Alberto              Errazuriz                      12000
Gerald               Cambrault                      11000
Eleni                Zlotkey                        10500
Peter                Tucker                         10000
David                Bernstein                       9500
Peter                Hall                            9000
Christopher          Olsen                           8000
Nanette              Cambrault                       7500

FIRST_NAME           LAST_NAME                     SALARY
-------------------- ------------------------- ----------
Oliver               Tuvault                         7000
Janette              King                           10000
Patrick              Sully                           9500
Allan                McEwen                          9000
Lindsey              Smith                           8000
Louise               Doran                           7500
Sarath               Sewall                          7000
Clara                Vishney                        10500
Danielle             Greene                          9500
Mattea               Marvins                         7200
David                Lee                             6800

FIRST_NAME           LAST_NAME                     SALARY
-------------------- ------------------------- ----------
Sundar               Ande                            6400
Amit                 Banda                           6200
Lisa                 Ozer                           11500
Harrison             Bloom                          10000
Tayler               Fox                             9600
William              Smith                           7400
Elizabeth            Bates                           7300
Sundita              Kumar                           6100
Ellen                Abel                           11000
Alyssa               Hutton                          8800
Jonathon             Taylor                          8600

FIRST_NAME           LAST_NAME                     SALARY
-------------------- ------------------------- ----------
Jack                 Livingston                      8400
Kimberely            Grant                           7000
Charles              Johnson                         6200
Winston              Taylor                          3200
Jean                 Fleaur                          3100
Martha               Sullivan                        2500
Girard               Geoni                           2800
Nandita              Sarchand                        4200
Alexis               Bull                            4100
Julia                Dellinger                       3400
Anthony              Cabrio                          3000

FIRST_NAME           LAST_NAME                     SALARY
-------------------- ------------------------- ----------
Kelly                Chung                           3800
Jennifer             Dilly                           3600
Timothy              Gates                           2900
Randall              Perkins                         2500
Sarah                Bell                            4000
Britney              Everett                         3900
Samuel               McCain                          3200
Vance                Jones                           2800
Alana                Walsh                           3100
Kevin                Feeney                          3000
Donald               OConnell                        2600

FIRST_NAME           LAST_NAME                     SALARY
-------------------- ------------------------- ----------
Douglas              Grant                           2600
Jennifer             Whalen                          4400
Michael              Hartstein                      13000
Pat                  Fay                             6000
Susan                Mavris                          6500
Hermann              Baer                           10000
Shelley              Higgins                        12008
William              Gietz                           8300

107 rows selected.

Pictorial Presentation:

Pictorial: Query to list first name, last name and their salary for employee contained in the employees table.

Improve this sample solution and post your code through Disqus.

Previous: Oracle Basic
Next:Write a query to display all the columns of employees table.

What is the difficulty level of this exercise?



Follow us on Facebook and Twitter for latest update.