Question

After creating the table below and inserting the values please write sql commands d. Count the...

After creating the table below and inserting the values please write sql commands

d. Count the different MARITALSTATUS when ATTRITION is YES in the dataset. Arrange the count in descending order (Hint: Use GROUP BY statement)

e. For each JOBROLE when the ATTRITION is No, find the average MONTHLYINCOME for only those employees having DAILYRATE greater than or equal to 110 (Hint: Use GROUP BY and HAVING statements together)

CREATE TABLE EMPLOYEEATTRITION (
AGE INT,
ATTRITION VARCAHR2(20),
BUSINESSTRAVEL VARCAHR2(20),
DAILYRATE INT,
DEPARTMENT VARCAHR2(20),
DISTANCEFROMHOME VARCAHR2(20),
EDUCATION INT,
EDUCATIONFIELD VARCAHR2(20),
EMPLOYEECOUNT INT,
EMPLOYEENUMBER INT,
ENVIRONMENTSATISFACTION INT,
GENDER VARCAHR2(20),
HOURLYRATE INT,
JOBINVOLVEMENT INT,
JOBLEVEL INT,
JOBROLE VARCHAR2(20),
JOBSATISFACTION INT,
MARITALSTATUS VARCAHR2(20),
MONTHLYINCOME INT,
MONTHLYRATE INT,
NUMCOMPANIESWORKED INT,
OVER18 VARCHAR2(20),
OVERTIME VARCHAR2(20),
PERCENTSALARYHIKE INT,
PERFORMANCERATING INT,
RELATIONSHIPSATISFACTION INT,
STANDARDHOURS INT,
STOCKOPTIONLEVEL INT,
TOTALWORKINGYEARS INT,
TRAININGTIMESLASTYEAR INT,
WORKLIFEBALANCE INT,
YEARSATCOMPANY INT,
YEARSINCURRENTROLE INT,
YEARSSINCELASTPROMOTION INT,
YEARSWITHCURRMANAGER INT,
PRIMARY KEY (AGE)
);

INSERT INTO EMPLOYEEATTRITION ( AGE, ATTRITION, BUSINESSTRAVEL, DAILYRATE, DEPARTMENT, DISTANCEFROMHOME, EDUCATION, EDUCATIONFIELD, EMPLOYEECOUNT, EMPLOYEENUMBER, ENVIRONMENTSATISFACTION, GENDER, HOURLYRATE, JOBINVOLVEMENT, JOBLEVEL, JOBROLE, JOBSATISFACTION, MARITALSTATUS, MONTHLYINCOME, MONTHLYRATE, NUMCOMPANIESWORKED, OVER18, OVERTIME, PERCENTSALARYHIKE, PERFORMANCERATING, RELATIONSHIPSATISFACTION, STANDARDHOURS, STOCKOPTIONLEVEL, TOTALWORKINGYEARS, TRAININGTIMESLASTYEAR, WORKLIFEBALANCE, YEARSATCOMPANY, YEARSINCURRENTROLE, YEARSSINCELASTPROMOTION, YEARSWITHCURRMANAGER ) VALUES ( 38, 'No', 'Travel_Rarely', 702, 'Sales', '1', 4, 'Life Sciences', 1, 230, 1, 'Female', 59, 2, 2, 'Sales Executive', 4, 'Single', 8686, 12930, 4, 'Y', 'No', 22, 4, 3, 80, 0, 12, 2, 4, 8, 3, 0, 7 );

INSERT INTO EMPLOYEEATTRITION ( AGE, ATTRITION, BUSINESSTRAVEL, DAILYRATE, DEPARTMENT, DISTANCEFROMHOME, EDUCATION, EDUCATIONFIELD, EMPLOYEECOUNT, EMPLOYEENUMBER, ENVIRONMENTSATISFACTION, GENDER, HOURLYRATE, JOBINVOLVEMENT, JOBLEVEL, JOBROLE, JOBSATISFACTION, MARITALSTATUS, MONTHLYINCOME, MONTHLYRATE, NUMCOMPANIESWORKED, OVER18, OVERTIME, PERCENTSALARYHIKE, PERFORMANCERATING, RELATIONSHIPSATISFACTION, STANDARDHOURS, STOCKOPTIONLEVEL, TOTALWORKINGYEARS, TRAININGTIMESLASTYEAR, WORKLIFEBALANCE, YEARSATCOMPANY, YEARSINCURRENTROLE, YEARSSINCELASTPROMOTION, YEARSWITHCURRMANAGER ) VALUES ( 32, 'No', 'Travel_Rarely', 120, 'Research & Development', '6', 5, 'Life Sciences', 1, 231, 3, 'Male', 43, 3, 1, 'Research Scientist', 3, 'Single', 3038, 12430, 3, 'Y', 'No', 20, 4, 1, 80, 0, 8, 2, 3, 5, 4, 1, 4 );

INSERT INTO EMPLOYEEATTRITION ( AGE, ATTRITION, BUSINESSTRAVEL, DAILYRATE, DEPARTMENT, DISTANCEFROMHOME, EDUCATION, EDUCATIONFIELD, EMPLOYEECOUNT, EMPLOYEENUMBER, ENVIRONMENTSATISFACTION, GENDER, HOURLYRATE, JOBINVOLVEMENT, JOBLEVEL, JOBROLE, JOBSATISFACTION, MARITALSTATUS, MONTHLYINCOME, MONTHLYRATE, NUMCOMPANIESWORKED, OVER18, OVERTIME, PERCENTSALARYHIKE, PERFORMANCERATING, RELATIONSHIPSATISFACTION, STANDARDHOURS, STOCKOPTIONLEVEL, TOTALWORKINGYEARS, TRAININGTIMESLASTYEAR, WORKLIFEBALANCE, YEARSATCOMPANY, YEARSINCURRENTROLE, YEARSSINCELASTPROMOTION, YEARSWITHCURRMANAGER ) VALUES ( 27, 'No', 'Travel_Rarely', 1157, 'Research & Development', '17', 3, 'Technical Degree', 1, 233, 3, 'Male', 51, 3, 1, 'Research Scientist', 2, 'Married', 3058, 13364, 0, 'Y', 'Yes', 16, 3, 4, 80, 1, 6, 3, 2, 5, 2, 1, 1 );

INSERT INTO EMPLOYEEATTRITION ( AGE, ATTRITION, BUSINESSTRAVEL, DAILYRATE, DEPARTMENT, DISTANCEFROMHOME, EDUCATION, EDUCATIONFIELD, EMPLOYEECOUNT, EMPLOYEENUMBER, ENVIRONMENTSATISFACTION, GENDER, HOURLYRATE, JOBINVOLVEMENT, JOBLEVEL, JOBROLE, JOBSATISFACTION, MARITALSTATUS, MONTHLYINCOME, MONTHLYRATE, NUMCOMPANIESWORKED, OVER18, OVERTIME, PERCENTSALARYHIKE, PERFORMANCERATING, RELATIONSHIPSATISFACTION, STANDARDHOURS, STOCKOPTIONLEVEL, TOTALWORKINGYEARS, TRAININGTIMESLASTYEAR, WORKLIFEBALANCE, YEARSATCOMPANY, YEARSINCURRENTROLE, YEARSSINCELASTPROMOTION, YEARSWITHCURRMANAGER ) VALUES ( 19, 'Yes', 'Travel_Frequently', 602, 'Sales', '1', 1, 'Technical Degree', 1, 235, 3, 'Female', 100, 1, 1, 'Sales Representative', 1, 'Single', 2325, 20989, 0, 'Y', 'No', 21, 4, 1, 80, 0, 1, 5, 4, 0, 0, 0, 0 );

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Dear Student ,

As per the requirement submitted above , kindly find the below solution.

This demonstration is using oracle Live SQL.

Question d:

SQL Query :

SELECT count(MARITALSTATUS) from EMPLOYEEATTRITION where ATTRITION like'Yes'
group by MARITALSTATUS;

Screen in Oracle Live SQL :

SQL Worksheet 56 57 SELECT count (MARITALSTATUS) from EMPLOYEEATTRITION where ATTRITION likeYes group by MARITALSTATUS 58 5

*********************************

Question e:

SQL Query :

SELECT JOBROLE,DAILYRATE,avg(MONTHLYINCOME) from EMPLOYEEATTRITION where ATTRITION like'No'
group by JOBROLE,DAILYRATE
having DAILYRATE>=110;

Screen in Oracle Live SQL :

SQL Worksheet 60 SELECT JOBROLE, DAILYRATE, avg (MONTHLYINCOME) from EMPLOYEEATTRITION where ATTRITION likeNo 61 group by JO

NOTE : PLEASE FEEL FREE TO PROVIDE FEEDBACK ABOUT THE SOLUTION.

Add a comment
Know the answer?
Add Answer to:
After creating the table below and inserting the values please write sql commands d. Count the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • After creating the table and inserting the information below, please Write SQL commands that find the...

    After creating the table and inserting the information below, please Write SQL commands that find the following: a. Count the total number of records in the table.b. How many unique JOBROLE are there in the dataset. Order them by alphabetical order from A to Z. c. Find EMPLOYEENUMBER, EDUCATIONFIELD, JOBROLE for all the employees whose AGE is greater than 50 and ATTRITION is YES CREATE TABLE EMPLOYEEATTRITION ( AGE INT, ATTRITION VARCAHR2(20), BUSINESSTRAVEL VARCAHR2(20), DAILYRATE INT, DEPARTMENT VARCAHR2(20), DISTANCEFROMHOME VARCAHR2(20),...

  • Write a pl/sql block of code that will make a reservation for a customer for any...

    Write a pl/sql block of code that will make a reservation for a customer for any destination. The destination id, number of peolpe going and date will be entered by the user. Your code should calculate the cost and enter the data in the sales table. No destination can have more than 10 people going during the same dates. If the number is greater than 10 raise 'Sold_out' exception and print a message 'Sorry we are sold out for ths...

  • drop table department cascade constraints; create table department ( Dname   varchar2(15)   not null, Dnumber int   not...

    drop table department cascade constraints; create table department ( Dname   varchar2(15)   not null, Dnumber int   not null, Mgr_ssn   char(9)   not null, mgr_start_date   Date, primary key (Dnumber), Unique    (Dname)); insert into DEPARTMENT values ('Research', '5', '333445555', '22-May-1988'); insert into DEPARTMENT values ('Administration', '4', '987654321', '01-Jan-1995'); insert into DEPARTMENT values ('Headquarters', '1', '888665555', '19-Jun-1981'); drop table employee cascade constraints; create table employee ( Fname   varchar2(15) not null, Minit   char(1), Lname   varchar2(15) not null, Ssn   char(9), Bdate   date, Address   varchar2(30), Sex   char(1),...

  • Create a procedure to update the sales history table following the requirements below. A table creation...

    Create a procedure to update the sales history table following the requirements below. A table creation script is provided below. a) Call the procedure: UPDATE_SALES_HISTORY (The procedure name is important for our scripts to test and grade your code; please do not rename it (otherwise our scripts will not run and your score will be 0). b) The procedure takes 2 parameters: (4-digit-year, 2-digit-month). Both parameters will be numeric, e.g., (2019, 11) will denote 2019 (year) and November (month). The...

  • I am using oracle sql developer to create some queries to generated reports and it is...

    I am using oracle sql developer to create some queries to generated reports and it is not working. I am not sure how to use count, group by, and order by. Help me fix my query and explain to me how you did, so can do it next time. Also, I have to convert this query to a stored procedure, so can you help me do it too? Here is my query: SELECT COUNT(GUEST.FIRSTNAME), GUEST.FIRSTNAME, GUEST.LASTNAME, GUEST.GUESTTYPE, RESERVATION.RESERVATIONDATE, GUEST.EMAIL, FROM...

  • I need help with the following SQL query for a company database (script given below). The...

    I need help with the following SQL query for a company database (script given below). The name of the Department. The number of employees working in that department. The number of different projects controlled by this department. The name of the project controlled by this department that has the maximum number of employees of the company working on it. The number of the above project. The cumulative sum of the number of employees of the company working on the projects...

  • Using the ch08_saleco database write a T-SQL query to display the customer code, invoice number invoice...

    Using the ch08_saleco database write a T-SQL query to display the customer code, invoice number invoice date, and invoice subtotal from invoice conditioned on the invoice subtotal is greater than $100 and from only customer codes 10011 and 10012. (hint: in) /* Database Systems, 8th Ed., Rob/Coronel */ /* Type of SQL : SQL Server */ CREATE TABLE CUSTOMER ( CUS_CODE int, CUS_LNAME varchar(15), CUS_FNAME varchar(15), CUS_INITIAL varchar(1), CUS_AREACODE varchar(3), CUS_PHONE varchar(8), CUS_BALANCE float(8) ); INSERT INTO CUSTOMER VALUES('10010','Ramas','Alfred','A','615','844-2573','0'); INSERT...

  • these are all tables please see the tables and questions are mentioned below please see that...

    these are all tables please see the tables and questions are mentioned below please see that all and I need answers asap please write proper answer it's an easy task and don't take much time please do it fast thanks in advance EMPLOYEE Remark Column Name EmployeeNumberINT Primary Key Yes No CHAR (25 CHAR (35 CHAR 25 NUMERIC INT CHAR (12 CHAR Name in the DEPARTMENT table Position No Number in the EMPLOYEE table Su OfficePhone EmailAddress No No No...

  • Connect to mySQL DBMS, open a SQL script file, navigate to CityJail.sql file and execute it...

    Connect to mySQL DBMS, open a SQL script file, navigate to CityJail.sql file and execute it to create tables and populate with the supplied data. If there are any errors in the script fix them. It is your job to find the errors and correct them. This is important. You will need correct data for future exercises in this module. Then answer all questions. Write the answer below each question then take screen shot of the result. This script builds...

  • Rewrite following code down below using Factory Pattern. -------------------------Staff.java--------------------------- import java.util.*; public class Staff extends Employee...

    Rewrite following code down below using Factory Pattern. -------------------------Staff.java--------------------------- import java.util.*; public class Staff extends Employee {    private int HourlyRate;    /**Constructor Staff which initiates the values*/    public Staff() {    super();    HourlyRate=0;    }    /**Overloaded constructor method    * @param ln last name    * @param fn first name    * @param ID Employee ID    * @param sex Sex    * @param hireDate Hired Date    * @param hourlyRate Hourly rate for the work...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT