Please note, this is a STATIC archive of website www.w3resource.com from 19 Jul 2022, cach3.com does not collect or store any user information, there is no "phishing" involved.
w3resource

SQLite Exercise: Display the job title, employee name, and the difference between the salary of the employee and minimum salary for the job

Write a query to display job title, employee name, and the difference between the salary of the employee and minimum salary for the job.

Sample table : employees


SQLite Code:

SELECT job_title, first_name, salary-min_salary 'Salary - Min_Salary' 
FROM employees 
NATURAL JOIN jobs;

Output:

job_title   first_name  Salary - Min_Salary
----------  ----------  -------------------
President   Steven      4000
Administra  Neena       2000
Administra  Lex         2000
Programmer  Alexander   5000
Programmer  Bruce       2000
Programmer  David       800
Programmer  Valli       800
Programmer  Diana       200
Finance Ma  Nancy       3800
Accountant  Daniel      4800
Accountant  John        4000
Accountant  Ismael      3500
Accountant  Jose Manue  3600
Accountant  Luis        2700
Purchasing  Den         3000
Purchasing  Alexander   600
Purchasing  Shelli      400
Purchasing  Sigal       300
Purchasing  Guy         100
Purchasing  Karen       0
Stock Mana  Matthew     2500
Stock Mana  Adam        2700
Stock Mana  Payam       2400
Stock Mana  Shanta      1000
Stock Mana  Kevin       300
Stock Cler  Julia       1200
Stock Cler  Irene       700
Stock Cler  James       400
Stock Cler  Steven      200
Stock Cler  Laura       1300
Stock Cler  Mozhe       800
Stock Cler  James       500
Stock Cler  TJ          100
Stock Cler  Jason       1300
Stock Cler  Michael     900
Stock Cler  Ki          400
Stock Cler  Hazel       200
Stock Cler  Renske      1600
Stock Cler  Stephen     1200
Stock Cler  John        700
Stock Cler  Joshua      500
Stock Cler  Trenna      1500
Stock Cler  Curtis      1100
Stock Cler  Randall     600
Stock Cler  Peter       500
Sales Mana  John        4000
Sales Mana  Karen       3500
Sales Mana  Alberto     2000
Sales Mana  Gerald      1000
Sales Mana  Eleni       500
Sales Repr  Peter       4000
Sales Repr  David       3500
Sales Repr  Peter       3000
Sales Repr  Christophe  2000
Sales Repr  Nanette     1500
Sales Repr  Oliver      1000
Sales Repr  Janette     4000
Sales Repr  Patrick     3500
Sales Repr  Allan       3000
Sales Repr  Lindsey     2000
Sales Repr  Louise      1500
Sales Repr  Sarath      1000
Sales Repr  Clara       4500
Sales Repr  Danielle    3500
Sales Repr  Mattea      1200
Sales Repr  David       800
Sales Repr  Sundar      400
Sales Repr  Amit        200
Sales Repr  Lisa        5500
Sales Repr  Harrison    4000
Sales Repr  Tayler      3600
Sales Repr  William     1400
Sales Repr  Elizabeth   1300
Sales Repr  Sundita     100
Sales Repr  Ellen       5000
Sales Repr  Alyssa      2800
Sales Repr  Jonathon    2600
Sales Repr  Jack        2400
Sales Repr  Kimberely   1000
Sales Repr  Charles     200
Shipping C  Winston     700
Shipping C  Jean        600
Shipping C  Martha      0
Shipping C  Girard      300
Shipping C  Nandita     1700
Shipping C  Alexis      1600
Shipping C  Julia       900
Shipping C  Anthony     500
Shipping C  Kelly       1300
Shipping C  Jennifer    1100
Shipping C  Timothy     400
Shipping C  Randall     0
Shipping C  Sarah       1500
Shipping C  Britney     1400
Shipping C  Samuel      700
Shipping C  Vance       300
Shipping C  Alana       600
Shipping C  Kevin       500
Shipping C  Donald      100
Shipping C  Douglas     100
Administra  Jennifer    1400
Marketing   Michael     4000
Marketing   Pat         2000
Human Reso  Susan       2500
Public Rel  Hermann     5500
Accounting  Shelley     3800
Public Acc  William     41003         Vollman
193         Everett     123         Vollman
194         McCain      123         Vollman
195         Jones       123         Vollman
196         Walsh       124         Mourgos
197         Feeney      124         Mourgos
198         OConnell    124         Mourgos
199         Grant       124         Mourgos
200         Whalen      101         Kochhar
201         Hartstein   100         King
202         Fay         201         Hartstein
203         Mavris      101         Kochhar
204         Baer        101         Kochhar
205         Higgins     101         Kochhar
206         Gietz       205         Higgins

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 display the job title and average salary of employees.
Next: Write a query to display the job history that was done by any employee who is currently drawing more than 10000 of salary.

What is the difficulty level of this exercise?