Question

Employee EmployeeAddress PK EmployeelD Address PK EmployeelD PK AddressID PK AddressID ContactID LoginID Title Gender HireDate BirthDate SalariedFLG VacationHours SickLeaveHours CurrentFLG ModifiedDate MaritalStatus AddressLine1 AddressLine2 City StateProvincelD PostalCode ModifiedDate AddressDate AddressType

Assume that Flags are 0 and 1. Please note all other assumptions with inline code comments.

a. Write a SQL query that will show them one value which represents the number of employees with more than 150 hours accrued vacation.

b. Write SQL ONE query that returns two rows: The first is a count of salaried employees with over 125 hours accrued vacation and the second result row is the count of non-salaried employees with over 125 hours accrued vacation.

c. Please write a SQL query that the administrative assistant can use to create mailing labels for their HOME address and fill in some variables for a form letter. Assume your query result window will allow the results to be saved to a tab delimited file format that the admin can import and auto-create labels/letters. The format should be as follows: EmployeeID, LoginID, Mr or Mrs, HireDate, VacationHours, AddressLine1, AddressLine2, City+State+Zip. Please sort the results by City Name in ascending alphabetical order. NOTE: Legal has confirmed non- salaried employees are not subject to accrual limits and should therefore NOT be included in the result set.

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

A) SELECT count(EmployeeID) FROM `employee` WHERE vacationHours>150.

This command Will count all the employee with count() functions whose vacationsHours are more than 150.

Below is the screenShot of the executed command

Your SQL query has been executed successfully SELECT count(EmployeeID) FROM 、employee、 WERE vacationours:15e Profiling [ Inline ] [ Edit ] [ Explain SQL ] [ Create PHP Code ] [ Refresh] Options count(EmployeelD)

B) SELECT * FROM(
(Select Count(EmployeeId) as Salaried from employee where SalariedFlg=1 and vacationHours >125) Salaried,
(Select Count(EmployeeID) as NONSalaried from employee where SalariedFlg=0 and vacationHours >125) NOMSalaried
)

This command is basically combining 2 queries into 1 as stated in the que we have to write 1 query in order to achive our goal. here select * from will display everything that will proceed the query. ist query will check if salariedFlg is 1 and vacationhours are greater than 125 than then it count those employees and will print them as salaried. same goes for NON salaried Employee, Secreenshot of this query

C) select employee.EmployeeID,employee.LoginID,employee.Title,employee.HireDate,employee.vacationHours,address.Addressline1,address.AddressLine2,concat(address.city, ", ",address.StateProvisionID,", ",address.postalcode) as address from employee, employee_address, address where employee.EmployeeId=employee_address.EmployeeID and employee_address.AddressId=address.AddressId and salariedFlg=1

In the above query we are selecting columns from respective tables like we have written employee.EmployeeID it means select employeeID from employee table. then we are checking the condition and here we are matching employeeID from employee table and employeeID from Employee_address table and addressID from adress table and addressId from employee_address Table in order to match address with their respective employees. concat function concatinates multiple columns into single column. screenshot for the command is below:

Add a comment
Know the answer?
Add Answer to:
Assume that Flags are 0 and 1. Please note all other assumptions with inline code comments....
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
  • Using the database: Write SQL queries for each of the questions below. 1. Find the media...

    Using the database: Write SQL queries for each of the questions below. 1. Find the media type which has 100 or more tracks. Print the name of such media type. Number of rows returned in the result = 3 A) Find the playlists which have one or more tracks that have never been purchased in California (CA). Print the Id, and the name of such playlists. Number of rows returned in the result = 18 B) Find the customers who...

  • Question for SQL in MS SQL Server Management Studio (Please don't use where clause for Joins...

    Question for SQL in MS SQL Server Management Studio (Please don't use where clause for Joins use from clause) Need to Create a Query because Northwind Traders has decided to increase their retail prices. Write a query that shows the product name, the current price, and the new price. Make sure the new price is listed to 2 decimal points. Follow below guidelines on new retail price: a.         If the category is beverages or dairy products, increase the price by...

  • can someone solve these quick please and thank you! sql chapter 4 Query #1: List the...

    can someone solve these quick please and thank you! sql chapter 4 Query #1: List the company name, contact name, contact title and the phone number for customers who HAVE NOT put in an order. Use an outer join. Query #2: Create a listing displaying the employee first name, last name and the full name (First name space Last Name) of the person they report to (Supervisor). This is a self-join. If an employee does not report to anyone then...

  • Questions are based on the Northwind database. a. A data dictionary (Excel file) that describes each...

    Questions are based on the Northwind database. a. A data dictionary (Excel file) that describes each of the tables. (Attached in question) b.    Write good, clean SQL that answers the following questions. c.     Separate your queries as I have done in the following example. End each query with a semicolon (;) and insert the word "go" between each query. Queries can span multiple lines if required. Select CustomerID from Customers; go Select Count(*) from Employees; go Select max(productID) from Products; 18. Produce...

  • Hi i need Help. i use MYSQL command line. THE QUESTION ARE BELOW please check the...

    Hi i need Help. i use MYSQL command line. THE QUESTION ARE BELOW please check the answer before you submit because sometimes query gives error thank you For Full database of SQL you can DOWNLOAD from this link: https://drive.google.com/file/d/1xh1TcBfMtvKoxvJr7Csgnts68fF53Q1t/view?usp=sharing ------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- What are the total sales for each year. Note that you will need to use the YEAR function. Order by year with the newest year first. ------------------------------------------------------- How many employees have no customers? ------------------------------------------------------------------ List the total sales for...

  • If possible please just send the SQL statement. Thank you Each question within deliverable 3 must begin on a new page and be sure to document the question as the title of each item at the top o...

    If possible please just send the SQL statement. Thank you Each question within deliverable 3 must begin on a new page and be sure to document the question as the title of each item at the top of each page. Also, using a 12-point font, include the SQL statement and then provide a screen shot of each query. The screen shots must include both the SQL statement and the results for each item below based on the data entered in...

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