Computer Science Homework Solutions
Problem
#134842

Questions 1-7 answers provided need SQL's for each.

With the file attached please answer in SQL form the following. Thanks...

1. Which employees (by name) have degrees? (the "answer" is Smith, Johnson and Williams)
SELECT at least the employee first and last names - SELECT other columns you think would be meaningful.

    HINT: do a JOIN between the employees and degrees table ON EMPLOYEE_ID...this will in effect help you translate the EMPLOYEE_IDs in the degree table into names.

2. Which employees (by name) do not have degrees? (the "answer" is Jones, Green, Reagan, Washington)
SELECT at least the employee first and last names.
    HINTS:
    - do a join LEFT OUTER JOIN between employees table and degrees table, keeping the employees table on the "left"
    - use "IS NULL" in the WHERE line: WHERE DEGREES.EMPLOYEE_ID Is Null;

3. Which employees (by name) have no children? (the "answer" is Johnson, Reagan and Washington) SELECT at least the employee first and last names.      
    
    HINT: exact same concepts apply as in Question 2

4. Which employee(s) (by name) have 2 or more children? Show a count of the number of children that the employee has AND only show those employees with 2 or more children. (the "answer" is Green (4 kids), Jones (2 kids), Smith (2 kids))
    HINT: To do this really easily, I'd suggest using two queries. (and when you use the 1st query in the 2nd query, you can refer to it just like referring to a table: query1.fieldname    OK, first: who has two or more children? Just count the employee IDs that appear in the children table more than once. At this point you should have as a query result the employee IDs and number of kids. Treat that query as a table (like I explain above) and do an inner join using the employees table so that you can get the employee names.  

5. Which employee(s) (by name) have a degree and at least one child? (the "answer" is Smith and Williams)

    HINT: If you did an inner join between the degree table and the children table you'd have the employee IDs of people with degrees and children, wouldn't you? You could treat that query as a table and do an inner join with the employee table in order to translate the employee IDs into names.

6. Which employee(s) (by name) have neither a degree nor a child? (the "answer" is Reagan and Washington)

    HINT: An easy way to approach this: do an OUTER JOIN (also using "IS NULL") between the employee table and the degree table to figure out who doesnt have a degree. Do the same with the employee table and the children table (to see who doesnt have children). Do an inner join between the results of the 2 queries to see where they intersect (to show who doesnt have a degree or a child).

7. For those employees who have kids, what is the average number of kids they have? (the "answer" is 2.25)

    HINT: First do a grouping of employee IDs and their count in the children table. Then perform a query on these query results, figuring the average of those counts.

Attached file(s):
Attachments
WK4_DB_ACCESS2000.mdb  View File

Solution Summary

Using JOIN and INNER/OUTTER JOIN to do some queries.

Solution
What is this?
By OTA - Overall OTA Rating
Yanfang Li, PhD - 4.9/5
Purchase Cost Now
$2.19 CAD (was ~$79.80)
Included in Download
  • Plain text response
  • Attached file(s):
    • answer.txt
    • WK4_DB_ACCESS2000.mdb
$2.19 Instant Download
Add to Cart
Why you can trust BrainMass.com
  • Your Information is Secure
  • Best Online Academic Help Service
  • Students find real academic Success
Related Solutions
  • Databases-natural JOIN, an equiJOlN, and an outer JOIN. - Hi, I need assistance to the enclosed problem in databases. Regards, 1. List the rows in each of the joined tables. Use the small database shown in Figure Q3.5 to illustrate the difference be ...
  • PQ #1 - I have a query that starts with the line: SELECT books.isbn, order_lines.isbn ...why would I want to see isbns from two different tables? What sort of query would warrant that - an inne ...
  • Outer Join - I have attached a Word document defining the dbo.Orders and dbo.Employees tables (Northwind database). The needed query is: List the EmployeeID, LastName, and FirstName of all employees who did not t ...
  • SQL query for Access - Using the week 2 attachment database attached here with this posting, I need to come up with the proper SQL to answer these six questions which are within the word document: I suppose each of the visu ...
  • Query Results - RIGHT Outer Join - Using the week 2 lecture database, if you wanted to see all the isbns from the books table and any matching isbns from the order_lines table, you'd want to do an outer join as such (because not every ...
Browse