SlideShare a Scribd company logo
1 of 4
1. Return the names, IDS, and average salary of the top 10 employees who are Senior Engineers
whose average salary is at least $110,000 in descending order.
2. Find the top ten employees (names, IDs and total wages) who earned equal to or more than
$200000 between 01/01/2000 and 01/01/2002. Order them in decreasing order. Assume salaries
change every 12 months. For simplicity, ignore salaries that started or ended outside of the date
range.
3. Use a subquery to display the employee number and bottom 10 average salaries of the
employees who are not 'Staff'.
It is for MySQL, so the statements are slightly fifferent than SQL etc.
Solution
CREATE TABLE employees (
emp_no INT(11) NOT NULL,
birth_date DATE NOT NULL,
first_name VARCHAR(14) NOT NULL,
last_name VARCHAR(16) NOT NULL,
gender ENUM(‘M’,’F’) NOT NULL,
hire_date DATE NOT NULL,
PRIMARY KEY(emp_no) );
CREATE TABLE departments (
dept_no CHAR(4) NOT NULL,
dept_name VARCHAR(40) NOT NULL,
PRIMARY KEY(dept_no) );
UNIQUE KEY(dept_name) );
CREATE TABLE dept_emp (
emp_no INT(11) NOT NULL,
dept_no CHAR(4) NOT NULL,
from_date DATE NOT NULL,
to_date DATE NOT NULL,
PRIMARY KEY(emp_no) ,
FOREIGN KEY(emp_no) REFERENCES employees(emp_no),
FOREIGN KEY(dept_no) REFERENCES departments(dept_no),
PRIMARY KEY(dept_no) );
CREATE TABLE dept_manager (
emp_no INT(11) NOT NULL,
dept_no CHAR(4) NOT NULL,
from_date DATE NOT NULL,
to_date DATE NOT NULL,
PRIMARY KEY(emp_no) ,
FOREIGN KEY(emp_no) REFERENCES employees(emp_no),
FOREIGN KEY(dept_no) REFERENCES departments(dept_no),
PRIMARY KEY(dept_no) );
CREATE TABLE salaries (
emp_no INT(11) NOT NULL,
salary INT(11) NOT NULL,
from_date DATE NOT NULL,
to_date DATE NOT NULL,
PRIMARY KEY(emp_no) );
FOREIGN KEY(emp_no) REFERENCES employees(emp_no)
);
CREATE TABLE titles (
emp_no INT(11) NOT NULL,
title VARCHAR(50) NOT NULL,
from_date DATE NOT NULL,
to_date DATE NOT NULL,
PRIMARY KEY(emp_no) );
FOREIGN KEY(emp_no) REFERENCES employees(emp_no)
);
WHERE avg(salary) > = $110000ORDER BY avg(salary)desc limit 0,10
2. SELECT CONCAT(last_name,first_name) AS emp_name,emp_no,salary  FROM
employees
WHERE salary>=$200000 BETWEEN 01-01-2000 AND 01-01-2001 AND|OR
salary>=$200000 BETWEEN 01-01-2001 AND 01-01-2002 ORDER BY salary desc limit 0,10
3. SELECT emp_no FROM employees
WHERE salary>(SELECT avg(salary)
FROM employees
WHERE NOT EXISTS (SELECT name FROM employees)
)
ORDER BY emp_no ASC
Top 10 Senior Engineers, Highest Earning Employees, Lowest Average Salaries

More Related Content

Similar to Top 10 Senior Engineers, Highest Earning Employees, Lowest Average Salaries

Nunes database
Nunes databaseNunes database
Nunes databaseRohini17
 
Basic Sql Handouts
Basic Sql HandoutsBasic Sql Handouts
Basic Sql Handoutsjhe04
 
Les09 (using ddl statements to create and manage tables)
Les09 (using ddl statements to create and manage tables)Les09 (using ddl statements to create and manage tables)
Les09 (using ddl statements to create and manage tables)Achmad Solichin
 
Oracle - Program with PL/SQL - Lession 05
Oracle - Program with PL/SQL - Lession 05Oracle - Program with PL/SQL - Lession 05
Oracle - Program with PL/SQL - Lession 05Thuan Nguyen
 
RELATIONAL DATABASES & Database designCIS276EmployeeNumFir.docx
RELATIONAL DATABASES & Database designCIS276EmployeeNumFir.docxRELATIONAL DATABASES & Database designCIS276EmployeeNumFir.docx
RELATIONAL DATABASES & Database designCIS276EmployeeNumFir.docxsodhi3
 
Oracle tips and tricks
Oracle tips and tricksOracle tips and tricks
Oracle tips and tricksYanli Liu
 
MySQL Indexing Crash Course
MySQL Indexing Crash CourseMySQL Indexing Crash Course
MySQL Indexing Crash CourseAaron Silverman
 
Project_2CIS405(GroupProject)
Project_2CIS405(GroupProject)Project_2CIS405(GroupProject)
Project_2CIS405(GroupProject)James Wu
 
Sql tutorial
Sql tutorialSql tutorial
Sql tutorialamitabros
 
More SQL in MySQL 8.0
More SQL in MySQL 8.0More SQL in MySQL 8.0
More SQL in MySQL 8.0Norvald Ryeng
 
Cis336 all i labs week 1 to week 7 devry university
Cis336 all i labs week 1 to week 7 devry universityCis336 all i labs week 1 to week 7 devry university
Cis336 all i labs week 1 to week 7 devry universityjskdhklsduopuo0980
 
Cis336 all i labs week 1 to week 7 devry university
Cis336 all i labs week 1 to week 7 devry universityCis336 all i labs week 1 to week 7 devry university
Cis336 all i labs week 1 to week 7 devry universityCIS339
 
Cis336 all i labs week 1 to week 7 devry university
Cis336 all i labs week 1 to week 7 devry universityCis336 all i labs week 1 to week 7 devry university
Cis336 all i labs week 1 to week 7 devry universityjackiechaner
 

Similar to Top 10 Senior Engineers, Highest Earning Employees, Lowest Average Salaries (20)

Nunes database
Nunes databaseNunes database
Nunes database
 
Basic Sql Handouts
Basic Sql HandoutsBasic Sql Handouts
Basic Sql Handouts
 
Les09
Les09Les09
Les09
 
Les09 (using ddl statements to create and manage tables)
Les09 (using ddl statements to create and manage tables)Les09 (using ddl statements to create and manage tables)
Les09 (using ddl statements to create and manage tables)
 
Oracle - Program with PL/SQL - Lession 05
Oracle - Program with PL/SQL - Lession 05Oracle - Program with PL/SQL - Lession 05
Oracle - Program with PL/SQL - Lession 05
 
RELATIONAL DATABASES & Database designCIS276EmployeeNumFir.docx
RELATIONAL DATABASES & Database designCIS276EmployeeNumFir.docxRELATIONAL DATABASES & Database designCIS276EmployeeNumFir.docx
RELATIONAL DATABASES & Database designCIS276EmployeeNumFir.docx
 
Oracle tips and tricks
Oracle tips and tricksOracle tips and tricks
Oracle tips and tricks
 
MySQL Indexing Crash Course
MySQL Indexing Crash CourseMySQL Indexing Crash Course
MySQL Indexing Crash Course
 
SQL.pptx
SQL.pptxSQL.pptx
SQL.pptx
 
Project_2CIS405(GroupProject)
Project_2CIS405(GroupProject)Project_2CIS405(GroupProject)
Project_2CIS405(GroupProject)
 
SQL PPT.pptx
SQL PPT.pptxSQL PPT.pptx
SQL PPT.pptx
 
4sem dbms(1)
4sem dbms(1)4sem dbms(1)
4sem dbms(1)
 
Mysql schema emp dept
Mysql schema emp deptMysql schema emp dept
Mysql schema emp dept
 
Les20
Les20Les20
Les20
 
Sql tutorial
Sql tutorialSql tutorial
Sql tutorial
 
More SQL in MySQL 8.0
More SQL in MySQL 8.0More SQL in MySQL 8.0
More SQL in MySQL 8.0
 
Writeable CTEs: The Next Big Thing
Writeable CTEs: The Next Big ThingWriteable CTEs: The Next Big Thing
Writeable CTEs: The Next Big Thing
 
Cis336 all i labs week 1 to week 7 devry university
Cis336 all i labs week 1 to week 7 devry universityCis336 all i labs week 1 to week 7 devry university
Cis336 all i labs week 1 to week 7 devry university
 
Cis336 all i labs week 1 to week 7 devry university
Cis336 all i labs week 1 to week 7 devry universityCis336 all i labs week 1 to week 7 devry university
Cis336 all i labs week 1 to week 7 devry university
 
Cis336 all i labs week 1 to week 7 devry university
Cis336 all i labs week 1 to week 7 devry universityCis336 all i labs week 1 to week 7 devry university
Cis336 all i labs week 1 to week 7 devry university
 

More from todd991

14- Which of the following is the correct name for NalICO- A- Sodiuns.docx
14- Which of the following is the correct name for NalICO- A- Sodiuns.docx14- Which of the following is the correct name for NalICO- A- Sodiuns.docx
14- Which of the following is the correct name for NalICO- A- Sodiuns.docxtodd991
 
14 Income tax is estimated at 40- of income- What factors other than e.docx
14 Income tax is estimated at 40- of income- What factors other than e.docx14 Income tax is estimated at 40- of income- What factors other than e.docx
14 Income tax is estimated at 40- of income- What factors other than e.docxtodd991
 
12-19 Notes Compare and contrast the Hubble Space Telescope with James.docx
12-19 Notes Compare and contrast the Hubble Space Telescope with James.docx12-19 Notes Compare and contrast the Hubble Space Telescope with James.docx
12-19 Notes Compare and contrast the Hubble Space Telescope with James.docxtodd991
 
12-5 Distribution of Cash Upon Liquidation Manley and Singh are partne.docx
12-5 Distribution of Cash Upon Liquidation Manley and Singh are partne.docx12-5 Distribution of Cash Upon Liquidation Manley and Singh are partne.docx
12-5 Distribution of Cash Upon Liquidation Manley and Singh are partne.docxtodd991
 
10- Consider the following data structure used for implementing a link.docx
10- Consider the following data structure used for implementing a link.docx10- Consider the following data structure used for implementing a link.docx
10- Consider the following data structure used for implementing a link.docxtodd991
 
10 Solution#include-iostream-h- #include-conio-h- #include-process-h-.docx
10 Solution#include-iostream-h- #include-conio-h- #include-process-h-.docx10 Solution#include-iostream-h- #include-conio-h- #include-process-h-.docx
10 Solution#include-iostream-h- #include-conio-h- #include-process-h-.docxtodd991
 
1-What are the consequences of long term unemployment- 2-Should the go.docx
1-What are the consequences of long term unemployment- 2-Should the go.docx1-What are the consequences of long term unemployment- 2-Should the go.docx
1-What are the consequences of long term unemployment- 2-Should the go.docxtodd991
 
1-What is the conjugate base of H2C2O4- 2-Which of the following acid.docx
1-What is the conjugate base of H2C2O4-  2-Which of the following acid.docx1-What is the conjugate base of H2C2O4-  2-Which of the following acid.docx
1-What is the conjugate base of H2C2O4- 2-Which of the following acid.docxtodd991
 
1-The fund financial statements for governmental funds should include.docx
1-The fund financial statements for governmental funds should include.docx1-The fund financial statements for governmental funds should include.docx
1-The fund financial statements for governmental funds should include.docxtodd991
 
1-To a young researcher- what are the advantages of using the method o.docx
1-To a young researcher- what are the advantages of using the method o.docx1-To a young researcher- what are the advantages of using the method o.docx
1-To a young researcher- what are the advantages of using the method o.docxtodd991
 
1-The party to receive a distribution of principal from an estate is l.docx
1-The party to receive a distribution of principal from an estate is l.docx1-The party to receive a distribution of principal from an estate is l.docx
1-The party to receive a distribution of principal from an estate is l.docxtodd991
 
1-Consider an organization with which you have been affiliated as an e.docx
1-Consider an organization with which you have been affiliated as an e.docx1-Consider an organization with which you have been affiliated as an e.docx
1-Consider an organization with which you have been affiliated as an e.docxtodd991
 
1-Astronomers estimate that a low-mass red dwarf star like Proxima Cen.docx
1-Astronomers estimate that a low-mass red dwarf star like Proxima Cen.docx1-Astronomers estimate that a low-mass red dwarf star like Proxima Cen.docx
1-Astronomers estimate that a low-mass red dwarf star like Proxima Cen.docxtodd991
 
1-a Which of TCP or UDP is connection-less- Which of TCP or UDP is con.docx
1-a Which of TCP or UDP is connection-less- Which of TCP or UDP is con.docx1-a Which of TCP or UDP is connection-less- Which of TCP or UDP is con.docx
1-a Which of TCP or UDP is connection-less- Which of TCP or UDP is con.docxtodd991
 
1- You align 2 lenses together with known focal lengths fi and fa- The.docx
1- You align 2 lenses together with known focal lengths fi and fa- The.docx1- You align 2 lenses together with known focal lengths fi and fa- The.docx
1- You align 2 lenses together with known focal lengths fi and fa- The.docxtodd991
 
1- What were some of the major work published by Thomas Maithus- emplo.docx
1- What were some of the major work published by Thomas Maithus- emplo.docx1- What were some of the major work published by Thomas Maithus- emplo.docx
1- What were some of the major work published by Thomas Maithus- emplo.docxtodd991
 
1- What are the advantages and disadvantages of each of sociologys mai.docx
1- What are the advantages and disadvantages of each of sociologys mai.docx1- What are the advantages and disadvantages of each of sociologys mai.docx
1- What are the advantages and disadvantages of each of sociologys mai.docxtodd991
 
1- What are the three fundamental elements of an effective security pr.docx
1- What are the three fundamental elements of an effective security pr.docx1- What are the three fundamental elements of an effective security pr.docx
1- What are the three fundamental elements of an effective security pr.docxtodd991
 
1- What are the various theories that we use to explain why people com.docx
1- What are the various theories that we use to explain why people com.docx1- What are the various theories that we use to explain why people com.docx
1- What are the various theories that we use to explain why people com.docxtodd991
 
1- Research has shown that a- homogeneous groups are more creative tha.docx
1- Research has shown that a- homogeneous groups are more creative tha.docx1- Research has shown that a- homogeneous groups are more creative tha.docx
1- Research has shown that a- homogeneous groups are more creative tha.docxtodd991
 

More from todd991 (20)

14- Which of the following is the correct name for NalICO- A- Sodiuns.docx
14- Which of the following is the correct name for NalICO- A- Sodiuns.docx14- Which of the following is the correct name for NalICO- A- Sodiuns.docx
14- Which of the following is the correct name for NalICO- A- Sodiuns.docx
 
14 Income tax is estimated at 40- of income- What factors other than e.docx
14 Income tax is estimated at 40- of income- What factors other than e.docx14 Income tax is estimated at 40- of income- What factors other than e.docx
14 Income tax is estimated at 40- of income- What factors other than e.docx
 
12-19 Notes Compare and contrast the Hubble Space Telescope with James.docx
12-19 Notes Compare and contrast the Hubble Space Telescope with James.docx12-19 Notes Compare and contrast the Hubble Space Telescope with James.docx
12-19 Notes Compare and contrast the Hubble Space Telescope with James.docx
 
12-5 Distribution of Cash Upon Liquidation Manley and Singh are partne.docx
12-5 Distribution of Cash Upon Liquidation Manley and Singh are partne.docx12-5 Distribution of Cash Upon Liquidation Manley and Singh are partne.docx
12-5 Distribution of Cash Upon Liquidation Manley and Singh are partne.docx
 
10- Consider the following data structure used for implementing a link.docx
10- Consider the following data structure used for implementing a link.docx10- Consider the following data structure used for implementing a link.docx
10- Consider the following data structure used for implementing a link.docx
 
10 Solution#include-iostream-h- #include-conio-h- #include-process-h-.docx
10 Solution#include-iostream-h- #include-conio-h- #include-process-h-.docx10 Solution#include-iostream-h- #include-conio-h- #include-process-h-.docx
10 Solution#include-iostream-h- #include-conio-h- #include-process-h-.docx
 
1-What are the consequences of long term unemployment- 2-Should the go.docx
1-What are the consequences of long term unemployment- 2-Should the go.docx1-What are the consequences of long term unemployment- 2-Should the go.docx
1-What are the consequences of long term unemployment- 2-Should the go.docx
 
1-What is the conjugate base of H2C2O4- 2-Which of the following acid.docx
1-What is the conjugate base of H2C2O4-  2-Which of the following acid.docx1-What is the conjugate base of H2C2O4-  2-Which of the following acid.docx
1-What is the conjugate base of H2C2O4- 2-Which of the following acid.docx
 
1-The fund financial statements for governmental funds should include.docx
1-The fund financial statements for governmental funds should include.docx1-The fund financial statements for governmental funds should include.docx
1-The fund financial statements for governmental funds should include.docx
 
1-To a young researcher- what are the advantages of using the method o.docx
1-To a young researcher- what are the advantages of using the method o.docx1-To a young researcher- what are the advantages of using the method o.docx
1-To a young researcher- what are the advantages of using the method o.docx
 
1-The party to receive a distribution of principal from an estate is l.docx
1-The party to receive a distribution of principal from an estate is l.docx1-The party to receive a distribution of principal from an estate is l.docx
1-The party to receive a distribution of principal from an estate is l.docx
 
1-Consider an organization with which you have been affiliated as an e.docx
1-Consider an organization with which you have been affiliated as an e.docx1-Consider an organization with which you have been affiliated as an e.docx
1-Consider an organization with which you have been affiliated as an e.docx
 
1-Astronomers estimate that a low-mass red dwarf star like Proxima Cen.docx
1-Astronomers estimate that a low-mass red dwarf star like Proxima Cen.docx1-Astronomers estimate that a low-mass red dwarf star like Proxima Cen.docx
1-Astronomers estimate that a low-mass red dwarf star like Proxima Cen.docx
 
1-a Which of TCP or UDP is connection-less- Which of TCP or UDP is con.docx
1-a Which of TCP or UDP is connection-less- Which of TCP or UDP is con.docx1-a Which of TCP or UDP is connection-less- Which of TCP or UDP is con.docx
1-a Which of TCP or UDP is connection-less- Which of TCP or UDP is con.docx
 
1- You align 2 lenses together with known focal lengths fi and fa- The.docx
1- You align 2 lenses together with known focal lengths fi and fa- The.docx1- You align 2 lenses together with known focal lengths fi and fa- The.docx
1- You align 2 lenses together with known focal lengths fi and fa- The.docx
 
1- What were some of the major work published by Thomas Maithus- emplo.docx
1- What were some of the major work published by Thomas Maithus- emplo.docx1- What were some of the major work published by Thomas Maithus- emplo.docx
1- What were some of the major work published by Thomas Maithus- emplo.docx
 
1- What are the advantages and disadvantages of each of sociologys mai.docx
1- What are the advantages and disadvantages of each of sociologys mai.docx1- What are the advantages and disadvantages of each of sociologys mai.docx
1- What are the advantages and disadvantages of each of sociologys mai.docx
 
1- What are the three fundamental elements of an effective security pr.docx
1- What are the three fundamental elements of an effective security pr.docx1- What are the three fundamental elements of an effective security pr.docx
1- What are the three fundamental elements of an effective security pr.docx
 
1- What are the various theories that we use to explain why people com.docx
1- What are the various theories that we use to explain why people com.docx1- What are the various theories that we use to explain why people com.docx
1- What are the various theories that we use to explain why people com.docx
 
1- Research has shown that a- homogeneous groups are more creative tha.docx
1- Research has shown that a- homogeneous groups are more creative tha.docx1- Research has shown that a- homogeneous groups are more creative tha.docx
1- Research has shown that a- homogeneous groups are more creative tha.docx
 

Recently uploaded

Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitolTechU
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxJiesonDelaCerna
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 

Recently uploaded (20)

Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptx
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptx
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 

Top 10 Senior Engineers, Highest Earning Employees, Lowest Average Salaries

  • 1. 1. Return the names, IDS, and average salary of the top 10 employees who are Senior Engineers whose average salary is at least $110,000 in descending order. 2. Find the top ten employees (names, IDs and total wages) who earned equal to or more than $200000 between 01/01/2000 and 01/01/2002. Order them in decreasing order. Assume salaries change every 12 months. For simplicity, ignore salaries that started or ended outside of the date range. 3. Use a subquery to display the employee number and bottom 10 average salaries of the employees who are not 'Staff'. It is for MySQL, so the statements are slightly fifferent than SQL etc. Solution CREATE TABLE employees ( emp_no INT(11) NOT NULL, birth_date DATE NOT NULL, first_name VARCHAR(14) NOT NULL, last_name VARCHAR(16) NOT NULL, gender ENUM(‘M’,’F’) NOT NULL, hire_date DATE NOT NULL, PRIMARY KEY(emp_no) ); CREATE TABLE departments ( dept_no CHAR(4) NOT NULL, dept_name VARCHAR(40) NOT NULL,
  • 2. PRIMARY KEY(dept_no) ); UNIQUE KEY(dept_name) ); CREATE TABLE dept_emp ( emp_no INT(11) NOT NULL, dept_no CHAR(4) NOT NULL, from_date DATE NOT NULL, to_date DATE NOT NULL, PRIMARY KEY(emp_no) , FOREIGN KEY(emp_no) REFERENCES employees(emp_no), FOREIGN KEY(dept_no) REFERENCES departments(dept_no), PRIMARY KEY(dept_no) ); CREATE TABLE dept_manager ( emp_no INT(11) NOT NULL, dept_no CHAR(4) NOT NULL, from_date DATE NOT NULL, to_date DATE NOT NULL, PRIMARY KEY(emp_no) , FOREIGN KEY(emp_no) REFERENCES employees(emp_no), FOREIGN KEY(dept_no) REFERENCES departments(dept_no), PRIMARY KEY(dept_no) ); CREATE TABLE salaries ( emp_no INT(11) NOT NULL, salary INT(11) NOT NULL,
  • 3. from_date DATE NOT NULL, to_date DATE NOT NULL, PRIMARY KEY(emp_no) ); FOREIGN KEY(emp_no) REFERENCES employees(emp_no) ); CREATE TABLE titles ( emp_no INT(11) NOT NULL, title VARCHAR(50) NOT NULL, from_date DATE NOT NULL, to_date DATE NOT NULL, PRIMARY KEY(emp_no) ); FOREIGN KEY(emp_no) REFERENCES employees(emp_no) ); WHERE avg(salary) > = $110000ORDER BY avg(salary)desc limit 0,10 2. SELECT CONCAT(last_name,first_name) AS emp_name,emp_no,salary  FROM employees WHERE salary>=$200000 BETWEEN 01-01-2000 AND 01-01-2001 AND|OR salary>=$200000 BETWEEN 01-01-2001 AND 01-01-2002 ORDER BY salary desc limit 0,10 3. SELECT emp_no FROM employees WHERE salary>(SELECT avg(salary) FROM employees WHERE NOT EXISTS (SELECT name FROM employees) ) ORDER BY emp_no ASC