Question

Write following queries given these schemas: (FK stands for Foreign Key) Customer = {customerID, firstName, lastName,...

Write following queries given these schemas:
(FK stands for Foreign Key)

  • Customer = {customerID, firstName, lastName, income, birthDate}
  • Account = {accNumber, type, balance, branchNumberFK-Branch}
  • Owns = {customerIDFK-Customer, accNumberFK-Account}
  • Transactions = {transNumber, accNumberFK-Account, amount}
  • Employee = {sin, firstName, lastName, salary, branchNumberFK-Branch}
  • Branch = {branchNumber, branchName, managerSINFK-Employee, budget}

Focus should be on using:

  • Order By to sort data
  • Set Operators to union/intersect multiple tables
  • Join Operator to join multiple tables
  • Aggregations and Group By to aggregate data
  • Subqueries

3.8 SIN, first name, last name, and salary of employees who earn more than $70,000, if they are managers show the branch name of their branch in a fifth column (which should be NULL/NONE for most employees), order by branch name. You must use an outer join in your solution (which is the easiest way to do it).

3.9 Exactly as question eight, except that your query cannot include any join operation.

3.10 Customer ID, first name, last name and income of customers who have income greater than 5000 and own accounts in all of the branches that Helen Morgan owns accounts in, order by income in descreasing order.

3.11 SIN, first name, last name and salary of the lowest paid employee (or employees) of the London branch, order by sin.

3.12 Branch name, and the difference of maximum and minimum (salary gap) and average salary of the employees at each branch, order by branch name.

3.13 Count of the number of employees working at the New York branch and Count of the number of different last names of employees working at the New Yorkbranch (two numbers in a single row).

3.14 Sum of the employee salaries (a single number) at the New York branch.

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

3.8

Select SIN,firstName,lastName,Salary , branchName from Employee left outer join Branch on Employee.SIN = Branch.ManagerSIN where Salary > 70000 order by branchName;

3.9

Select SIN,firstName, lastName, Salary , branchName from Employee ,Branch where Salary > 70000 and Employee.SIN = Branch.ManagerSIN order by branchName;

3.10

Select Customer.CustomerId, firstName, lastName, income from customer inner join Owns on Customer. CustomerId = Owns.CustomerId inner join Account on Owns.accNumber = Account.accNumber where income > 5000 and firstName = 'Helen' and lastName = 'Morgan' order by income desc;

3.11

Select SIN,firstName,lastName,Salary from Employee inner join Branch on Employee.branchNumber = Branch.branchNumber where branchName = 'London' and Salary = (Select min(Salary) from Employee) order by SIN;

3.12

Select branchName, max(Salary)-min(Salary) as 'SalaryGap', avg(Salary) from Employee inner join Branch on Employee.branchNumber = Branch.branchNumber group by branchName order by branchName;

3.13

Select count(Employee.SIN), count(distinct lastName) from Employee inner join Branch on Employee.branchNumber = Branch.branchNumber where branchName = 'New York'

3.14

Select sum(Salary) from Employee inner join Branch on Employee.branchNumber = Branch.branchNumber where branchName = 'New York';

Do ask if any doubt. Please upvote.

Add a comment
Know the answer?
Add Answer to:
Write following queries given these schemas: (FK stands for Foreign Key) Customer = {customerID, firstName, lastName,...
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
  • Write following queries given these schemas: (FK stands for Foreign Key) Customer = {customerID, firstName, lastName,...

    Write following queries given these schemas: (FK stands for Foreign Key) Customer = {customerID, firstName, lastName, income, birthDate} Account = {accNumber, type, balance, branchNumberFK-Branch} Owns = {customerIDFK-Customer, accNumberFK-Account} Transactions = {transNumber, accNumberFK-Account, amount} Employee = {sin, firstName, lastName, salary, branchNumberFK-Branch} Branch = {branchNumber, branchName, managerSINFK-Employee, budget} Focus should be on using: Order By to sort data Set Operators to union/intersect multiple tables Join Operator to join multiple tables Aggregations and Group By to aggregate data Subqueries 3.15 Customer ID, first...

  • SQL queries and procedures TABLE: Employees Business Rules: EmployeeID is defined as the primary key. Address...

    SQL queries and procedures TABLE: Employees Business Rules: EmployeeID is defined as the primary key. Address has been denormalized to include City and State for performance reasons. DeptNbr is a foreign key that references DeptNbr in the Department table Manager is a foreign key that references EmployeeID in the Employees table Data Structure: (EmployeeId, LastName, FirstName, Street, City, State, Zip, DateOfHire, DateOfBirth, JobTitle, Salary, DeptNbr(fk), Manager(fk)) TABLE: Department Business Rules: DeptNbr is defined as the primary key. Data Structure: (DeptNbr,...

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

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

  • Create the Employee class: The Employee class has three attributes: private: string firstName; string lastName; string...

    Create the Employee class: The Employee class has three attributes: private: string firstName; string lastName; string SSN; The Employee class has ▪ a no-arg constructor (a no-arg contructor is a contructor with an empty parameter list): In this no-arg constructor, use “unknown” to initialize all private attributes. ▪ a constructor with parameters for each of the attributes ▪ getter and setter methods for each of the private attributes ▪ a method getFullName() that returns the last name, followed by a...

  • Customer (CustomerId, CustomerName) Employee (EmployeeId, EmployeeName, Salary, SupervisorId) Product(ProductId, ProductName, ListPrice) Orders (OrderId, OrderDate, CustomerId, EmployeeId,...

    Customer (CustomerId, CustomerName) Employee (EmployeeId, EmployeeName, Salary, SupervisorId) Product(ProductId, ProductName, ListPrice) Orders (OrderId, OrderDate, CustomerId, EmployeeId, Total) OrderedProduct (OrderId, ProductId, Quantity, Price) Write the code to complete the methods in OrderJDBC.java (look for TODO items). <---**IN BOLD** throughout code. /* OrderJDBC.java - A JDBC program for accessing and updating an order database on MySQL. */ import java.io.File; import java.math.BigDecimal; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.sql.SQLException; import java.sql.Statement; import java.util.Scanner; /** * An application for...

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

  • I NEED TO WRITE THE FOLLOWING QUERIES IN MYSQL (13)Next, grant to a user admin the read privileges on the complete descr...

    I NEED TO WRITE THE FOLLOWING QUERIES IN MYSQL (13)Next, grant to a user admin the read privileges on the complete descriptions of the customers who submitted no orders. For example, these are the customers who registered themselves and submitted no orders so far. The granted privilege cannot be propagated to the other users. 0.3 (14)Next, grant to a user admin the read privileges on information about the total number of orders submitted by each customer. Note, that some customers...

  • Use program control statements in the following exercises: Question 1 . Write pseudocode for the following:...

    Use program control statements in the following exercises: Question 1 . Write pseudocode for the following: • Input a time in seconds. • Convert this time to hours, minutes, and seconds and print the result as shown in the following example: 2 300 seconds converts to 0 hours, 38 minutes, 20 seconds. Question 2. The voting for a company chairperson is recorded by entering the numbers 1 to 5 at the keyboard, depending on which of the five candidates secured...

  • Step 1 You work for Thunderduck Custom Tables Inc. This is the first month of operations. The company designs and manufactures specialty tables. Each table is specially customized for the customer. This month, you have been asked to develop and manufactu

    Step 1You work for Thunderduck Custom Tables Inc.  This is the first month of operations. The company designs and manufactures specialty tables. Each table is specially customized for the customer. This month, you have been asked to develop and manufacture two new tables for customers.  You will design and build the tables. This is a no nail, no screw, and no glue manufacturing ( no indirect materials used). You will be keeping track of the costs incurred to manufacture the...

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