w3resource

SQLite Exercise: Get monthly salary of each and every employee

Write a query to get monthly salary (round 2 decimal places) of each and every employee?

Sample table : employees


SQLite Code :

SELECT first_name, last_name, round(salary/12,2) as 'Monthly Salary' 
FROM employees;

Output:

first_name  last_name   Monthly Sal
----------  ----------  -----------
Steven      King        2000.0
Neena       Kochhar     1416.0
Lex         De Haan     1416.0
Alexander   Hunold      750.0
Bruce       Ernst       500.0
David       Austin      400.0
Valli       Pataballa   400.0
Diana       Lorentz     350.0
Nancy       Greenberg   1000.0
Daniel      Faviet      750.0
John        Chen        683.0
Ismael      Sciarra     641.0
Jose Manue  Urman       650.0
Luis        Popp        575.0
Den         Raphaely    916.0
Alexander   Khoo        258.0
Shelli      Baida       241.0
Sigal       Tobias      233.0
Guy         Himuro      216.0
Karen       Colmenares  208.0
Matthew     Weiss       666.0
Adam        Fripp       683.0
Payam       Kaufling    658.0
Shanta      Vollman     541.0
Kevin       Mourgos     483.0
Julia       Nayer       266.0
Irene       Mikkilinen  225.0
James       Landry      200.0
Steven      Markle      183.0
Laura       Bissot      275.0
Mozhe       Atkinson    233.0
James       Marlow      208.0
TJ          Olson       175.0
Jason       Mallin      275.0
Michael     Rogers      241.0
Ki          Gee         200.0
Hazel       Philtanker  183.0
Renske      Ladwig      300.0
Stephen     Stiles      266.0
John        Seo         225.0
Joshua      Patel       208.0
Trenna      Rajs        291.0
Curtis      Davies      258.0
Randall     Matos       216.0
Peter       Vargas      208.0
John        Russell     1166.0
Karen       Partners    1125.0
Alberto     Errazuriz   1000.0
Gerald      Cambrault   916.0
Eleni       Zlotkey     875.0
Peter       Tucker      833.0
David       Bernstein   791.0
Peter       Hall        750.0
Christophe  Olsen       666.0
Nanette     Cambrault   625.0
Oliver      Tuvault     583.0
Janette     King        833.0
Patrick     Sully       791.0
Allan       McEwen      750.0
Lindsey     Smith       666.0
Louise      Doran       625.0
Sarath      Sewall      583.0
Clara       Vishney     875.0
Danielle    Greene      791.0
Mattea      Marvins     600.0
David       Lee         566.0
Sundar      Ande        533.0
Amit        Banda       516.0
Lisa        Ozer        958.0
Harrison    Bloom       833.0
Tayler      Fox         800.0
William     Smith       616.0
Elizabeth   Bates       608.0
Sundita     Kumar       508.0
Ellen       Abel        916.0
Alyssa      Hutton      733.0
Jonathon    Taylor      716.0
Jack        Livingston  700.0
Kimberely   Grant       583.0
Charles     Johnson     516.0
Winston     Taylor      266.0
Jean        Fleaur      258.0
Martha      Sullivan    208.0
Girard      Geoni       233.0
Nandita     Sarchand    350.0
Alexis      Bull        341.0
Julia       Dellinger   283.0
Anthony     Cabrio      250.0
Kelly       Chung       316.0
Jennifer    Dilly       300.0
Timothy     Gates       241.0
Randall     Perkins     208.0
Sarah       Bell        333.0
Britney     Everett     325.0
Samuel      McCain      266.0
Vance       Jones       233.0
Alana       Walsh       258.0
Kevin       Feeney      250.0
Donald      OConnell    216.0
Douglas     Grant       216.0
Jennifer    Whalen      366.0
Michael     Hartstein   1083.0
Pat         Fay         500.0
Susan       Mavris      541.0
Hermann     Baer        833.0
Shelley     Higgins     1000.0
William     Gietz       691.0

Practice SQLite Online


Model Database

Employee Model  Database - w3resource online SQLite practice

Structure of 'hr' database :

hr database

Improve this sample solution and post your code through Disqus.

Previous: Write a query to select first 10 records from a table.
Next: Simple select statements

What is the difficulty level of this exercise?



Share this Tutorial / Exercise on : Facebook and Twitter