Formulate sql queries

Assignment Help Database Management System
Reference no: EM13850659

Consider the following instance of this database. The Primary key (PK) and Foreign Keys (FK) are identified for each table.

Table: EMPLOYEE

PK: employeeID;

FK: empBranch references BRANCH;

FK: empSupervisor references EMPLOYEE

 

EMPLOYEEID

EMPLNAME

EMPFNAME

EMPTITLE

EMPSTARTDATE

EMPBRANCH

EMPSALARY

EMPSUPERVISOR

e1

Adam

Alan

CEO

11-JAN-02

b1

600000

-

e2

Bryson

Brad

branch_manager

01-FEB-03

b2

400000

e1

e3

Clay

Cedric

branch_manager

21-JUN-01

b3

450000

e1

e4

Day

Daisy

branch_manager

17-AUG-03

b4

480000

e1

e5

Engle

Eva

salesperson

01-JAN-04

b2

120000

e2

e6

Falcon

Fred

salesperson

01-JAN-02

b2

80000

e2

e7

Gandhi

Gagan

salesperson

01-JAN-03

b3

90000

e3

e8

Hee

Hwang

salesperson

01-JUN-04

b3

95000

e3

e9

Ingram

Irene

salesperson

24-SEP-02

b4

110000

e4

e10

Jerome

John

salesperson

25-AUG-02

b4

75000

e4

 Table: BRANCH

PK: branchNumber

FK: branchManager references EMPLOYEE

BRANCHNUMBER

BRANCHNAME

BRANCHSTREET

BRANCHCITY

BRANCHSTATE

BRANCHZIP

REVENUETARGET

BRANCHMANAGER

b1

branch1

9700 NW 41 St

Miami

FL

33178

800000

e1

b2

branch2

8700 SW 24 St

Miami

FL

33170

600000

e2

b3

branch3

E 200 47 St

New York

NY

11010

1000000

e3

b4

branch4

300 Park Avenue

New York

NY

10010

1200000

e4

Table: CUSTOMER

PK: customerID

CUSTOMERID

CUSTNAME

CUSTSTREET

CUSTCITY

CUSTSTATE

CUSTZIP

CUSTPHONE

c1

cust1

-

Miami

FL

33164

-

c2

cust2

-

Miami

FL

33120

-

c3

cust3

-

Miami

FL

33110

-

c4

cust4

-

Miami

FL

33178

-

c5

cust5

-

New York

NY

11021

-

c6

cust6

-

New York

NY

11001

-

Table: PRODUCT

PK: productCode

PRODUCTCODE

PRODDESCRIPTION

PRICE

STOCKLEVEL

p1

carpet

40

10000

p2

tile

20

100000

p3

pergo

50

50000

 Table: INSTALLATION

PK: installationType

INSTALLTYPE

INSTALLDESCRIPTION

RATE

i1

carpet installation

40

i2

tile installation

50

i3

pergo installation

60

Table: ORDERS

PK: orderNumber

FK: customerID references CUSTOMER;

FK: salesPerson references EMPLOYEE

 

ORDERNUMBER

ORDDATE

SALESPERSON

CUSTOMERID

o1

12-AUG-07

e5

c1

o2

14-DEC-07

e5

c2

o3

04-NOV-07

e5

c3

o4

15-AUG-07

e5

c4

o5

22-NOV-07

e10

c5

o6

01-JUL-07

e10

c6

o7

12-DEC-07

e6

c6

o8

30-NOV-07

e9

c2

  Table: PRODLINE

PK: orderNumber + prodCode

FK: orderNumber references ORDERS;

FK: prodCode references PRODUCT

ORDERNUMBER

PRODCODE

QUANTITY

o1

p1

1000

o1

p2

500

o2

p3

200

o3

p1

600

o3

p3

100

o4

p2

1000

o5

p2

800

 Table: INSTLINE

PK: orderNumber + instType

FK: orderNumber references ORDERS;

FK: instType references INSTALLATION

ORDERNUMBER

INSTTYPE

HOURS

o1

i1

20

o1

i2

30

o1

i3

10

o2

i1

10

o2

i2

20

o6

i1

20

o6

i2

10

o7

i3

10

o8

i2

20

Formulate SQL queries for the following (1 -6) with reference to this database. Present your SQL query and the results returned for the specified instance of the database. Your queries should work for EVERY instance of the database (and not just for the instance specified in this document).


(1) For each employee with a salary greater than $120,000, list the employee's id (employeeid), last name (emplname), and salary (empsalary) as "high_salary". Records should appear in descending order of salary.


(2) For each branch list the branchnumber and the sum total of salary paid to all employees working for that branch as "branch_payroll". Records should appear in descending order of branchnumber.


(3) List the order number, order date (orddate), and customer id (customerid) for all orders placed by customers located in the state of New York ( 'NY'). Records should appear in descending order of order number.


(4) For each order, list the ordernumber and the total revenue generated from installation services as "installation_revenue". Installation revenue for an order is computed as the sum of the hours times the rate of all installation services sold as part of that order.


(5) For each State list the "State_install_revenue" computed as the sum of the installation revenue (as defined in query 4 above) from all orders placed by customers located in that state (custstate).


(6) Under a column header "install_only_orders", list the order numbers for orders that include installation services but do not include any products.

Reference no: EM13850659

Questions Cloud

Analyzing moral issues in professional environments : Implementation Theory which includes the chart - Analyzing Moral Issues in Professional Environments, Boston: Pearson Education Company, 2006 - Implementation Theory which includes the chart.
Explain what is the price elasticity of demand : The price of a bag of pretzels rises from $2 to $3 and the quantity demanded decreases from 100 to 60. What is the price elasticity of demand
About the number of shares : Carson Corporation stock sells for $53 per share, and you've decided to purchase as many shares as you possibly can. You have $54,000 available to invest. What is the maximum number of shares you can buy if the initial margin is 70 percent?
Calculate current cost of equity-value of equity-price share : Copper company CCT has three million common shares outstanding and perpetual debt with a market value of $30 million. Its interest rate is 8%, and its corporate tax rate is 40%. Its levered beta is 1.2. The risk-free rate is 3% and the market portfol..
Formulate sql queries : Formulate SQL queries
Key for planning out the scheme for handling the scope : Initiating: What activities would be important to define and authorize the project or phase during this quarter's project? Planning: What activities would be key for planning out the scheme for handling the scope, schedule, costs, or resource usage
Why decision making usually requires change : We have discussed in class that decision making usually requires change and that in turn may bring about another decision. Review Jackson's decisions and write a one page epilogue to his decision making. Was it effective
Computers operates plant with annual capacity : A manufacturer of laptop computers operates a plant with an annual capacity of 6,630,000 laptop units. One of its models is expected to sell 390,000 units in the coming year. How large should each product lot be if it costs $575 to change production ..
What is the convective heat transfer coefficient : What is the convective heat transfer coefficient, h, for A = 0.125 m2, Tb = 200oC, Tf = 25oC and Qc = 8.75W.

Reviews

Write a Review

Database Management System Questions & Answers

  Write table in dbdl notation after applying methodology

Proceed with all steps in information-level design to add this user view to existing cumulative design. Is this table in1st NF?___No____ . If Yes skip. If not, write Table in DBDL notation after applying the methodology we use for converting into 1NF..

  Describe the various network implementations

The marking scheme, which is given in detail below, particularly rewards the way in which you relate your specific proposals to the material presented in the Course.

  Consider the scenario from exercise 2.4 where you designed

Consider the scenario from Exercise 2.4, where you designed an ER diagram for a company database. Write SQL statements to create the corresponding relations and capture as many of the constraints as possible. If you cannot capture some constraints, e..

  Create an initial erd for the new system

Create an initial ERD for the new system that contains at least eight entities. Analyze each relationship to determine if it is 1:1, 1:M, or M:N

  Develop an e-r diagram for the library database

Develop an E-R diagram for the library database. The relation schemas for the library database.

  Create a provider database and related reports

Create a provider database and related reports and queries to capture contact information for potential PC componentproviders that might be used to purchase the equipment your specified in your MS Word project - the PC specifications

  Imagine that you work for a consulting firm that offers

imagine that you work for a consulting firm that offers information technology and database services. part of its core

  Create an instance function in the inventorymanager

Create an instance function in the InventoryManager class called getDatabaseConnection. This function should

  Create a conceptual model of a database

create a conceptual database model using MS Visio Database Model Diagram Template. The purpose of this lab is to have you gain experience with the various modeling tools needed to create a conceptual model of a database

  Estimated costs and expected activity

Abel Company uses activity-based costing. The company has two products - estimated costs and expected activity

  Create a sql statement and execute the same in sqlplus

Statistics can be created on tables, indexes columns and as well as on the individual columns. But, if for some reason table or index statistics have not been updated, then this may result in a full table scan.

  What benefits could be gained from using a team to develop

describe the advantages and challenges of using a team to develop a microsoft access database. assignment guidelines

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd