Question

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),
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 SQL Live.

Question 1:

SQL Query :

select count(*) from EMPLOYEEATTRITION;

Screen in Oracle SQL Live :

SOL Worksheet 49 50 select count (*) from EMPLOYEEATTRITION; 51 53 54 COUNT () Download CSv st un un n

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

Question 2:

SQL Query :

select distinct(JOBROLE) from EMPLOYEEATTRITION order by JOBROLE asc;

Screen in Oracle SQL Live :

SQL Worksheet 52 select distinct (J0BROLE) from EMPLOYEEATTRITION order by JOBROLE asc; 53 54 55 56 J0BROLE Research Scientis

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

Question 3:

SQL Query :

select EMPLOYEENUMBER, EDUCATIONFIELD, JOBROLE from EMPLOYEEATTRITION where AGE > 50 and ATTRITION='YES';

Screen in Oracle SQL Live :

SQL Worksheet EMPLOYEEATTRITION where AGE 50 and ATTRITION YES ; 55 select EMPLOYEENUMBER, EDUCATIONFIELD, JOBROLE from 56 5

Here no employee with age >50;

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

Add a comment
Know the answer?
Add Answer to:
After creating the table and inserting the information below, please Write SQL commands that find 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 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...

  • 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),...

  • I need help for SQL homework. the question: the code for part 1,2: drop table Customer;...

    I need help for SQL homework. the question: the code for part 1,2: drop table Customer; drop table Company; drop table Cruise; drop table TravelAgent; drop table Reservation; drop sequence customerID_seq; drop sequence cruiseID_seq; drop sequence travelAgentID_seq; drop sequence reservationID_seq; create table Customer( customerID number, firstName varchar2(15), lastName varchar2(15), address varchar2(30), phone number(10) not null, age number(3), Constraint Customer_PK Primary Key (customerID), constraint Customer_unique unique (firstName,lastName,phone), constraint Customer_check check(phone is not null) ); create sequence customerID_seq start with 1 increment...

  • 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...

  • Please help me on the SQL queries, thank you so much. Write a query to display the title and publisher as well as the p...

    Please help me on the SQL queries, thank you so much. Write a query to display the title and publisher as well as the publisher contact for each book using JOIN...USING clause. Write a query to show the first and last names of customers who have ordered cooking books. Use the WHERE clause to join the tables. Write a query to show the title, cost and ISBN of each book in the books table. If the book has been ordered,...

  • please write a file with the commands attached SQL commans For this assignment, submit a text...

    please write a file with the commands attached SQL commans For this assignment, submit a text file with the commands that you entered into your MySQL database on burrow to do the following: 1. (25 points) Create a table called Singer, when described it should have the following values: | Field I Type I Null Key Default l Extra | SingerID int (11) | FirstName | varchar (30) YESI I LastName varchar (30) YES I | Label | Salary I...

  • 8.Write the commands to obtain the following information from the systems catalog. List every table that...

    8.Write the commands to obtain the following information from the systems catalog. List every table that you own, list every column in the PART table and its associated data type, then add ORDER_NUM as a foreign key in the ORDER_LINE table. this is the SQL for the database: CREATE DATABASE PREMIERE; USE PREMIERE; CREATE TABLE REP (REP_NUM CHAR(2) PRIMARY KEY, LAST_NAME CHAR(15), FIRST_NAME CHAR(15), STREET CHAR(15), CITY CHAR(15), STATE CHAR(2), ZIP CHAR(5), COMMISSION DECIMAL(7,2), RATE DECIMAL(3,2) ); CREATE TABLE CUSTOMER...

  • 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...

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