Question

Please help I promise positive feedback Part IV. Formulate SQL queries that follow for the database...

Please help I promise positive feedback

Part IV. Formulate SQL queries that follow for the database with the following tables: CUSTOMER, PRODUCT, SALES, and ITEM-SOLD.

Table: CUSTOMER

Primary Key: Account-No

Account-No

Customer-Name

Customer-City

1

A

NYC

2

B

NYC

3

C

MIA

Table: PRODUCT

Primary Key: Item-No

Item-No

Price

1

$1.00

2

$2.00

3

$3.00

4

$4.00

Table: SALES

Primary Key: Receipt-No

Foreign Key: Account-No References CUSTOMER

Receipt-No

Account-No

Sales-Person

1

1

S1

2

1

S1

3

2

S2

4

3

S3

Table: ITEM-SOLD

Primary Key: Receipt-No + Item-No

Foreign Key: Receipt-No References SALES

Foreign Key: Item-No References PRODUCT

Receipt-No

Item-No

Quantity

1

1

10

1

2

20

1

3

30

2

1

10

2

2

20

3

1

10

4

1

10

4

4

40

  1. List the Receipt-No and Customer-Name for all sales transactions involving customers in NYC.
  2. For each Receipt-No list the total amount as Total-Amount. Total-Amount is computed as the sum of the product of quantity and price for all items sold in that sales transaction (Receipt-no). For example, the Total-Amount for Receipt-No 1 is 10 x 1.00 + 20 x 2.00 + 30 x 3.00 = $140.00.
  3. List the Item-No for products that were sold to every customer.
  4. For each Product list the total quantity sold as Total-Quantity-Sold.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

a) SELECT s.Receipt-No, c.Customer-Name FROM CUSTOMER c JOIN SALES s ON c.Account-No = s.Account-No WHERE c.Customer-City = 'NYC';

b) SELECT is.Receipt-No, sum(is.Quantity * p.Price) FROM ITEM-SOLD is JOIN PRODUCT p ON is.Item-No = p.Item-No;

d) SELECT sum(Quantity) AS 'Total-Quantity-Sold' FROM ITEM-SOLD GROUP BY Item-No;

NOTE: As per Chegg policy, I am allowed to answer only 3 questions (including sub-parts) on a single post. Kindly post the remaining questions separately and I will try to answer them. Sorry for the inconvenience caused.

Add a comment
Know the answer?
Add Answer to:
Please help I promise positive feedback Part IV. Formulate SQL queries that follow for the database...
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
  • 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,...

  • SQL I have a database CREATE TABLE vendor ( vid CHAR(2) NOT NULL, vname VARCHAR(25) NOT...

    SQL I have a database CREATE TABLE vendor ( vid CHAR(2) NOT NULL, vname VARCHAR(25) NOT NULL, PRIMARY KEY (vid) ); CREATE TABLE category ( catid CHAR(2) NOT NULL, catname VARCHAR(25) NOT NULL, PRIMARY KEY (catid) ); CREATE TABLE product ( pid CHAR(3) NOT NULL, pname VARCHAR(25) NOT NULL, price NUMERIC (7,2) NOT NULL, vid CHAR(2) NOT NULL, categoryid CHAR(2) NOT NULL, PRIMARY KEY (pid)); CREATE TABLE region ( rid CHAR NOT NULL, rname VARCHAR(25) NOT NULL, PRIMARY KEY (rid)...

  • Write SQL statements to answer the following questions using Assignment 3’s schema (tables from part 1)....

    Write SQL statements to answer the following questions using Assignment 3’s schema (tables from part 1). 1- Find how many branches had have loans over $2000.00. 2- For each branch, find the most expensive loan. Your output should include Branch Id, loan amount for the highest loan for that Branch. 3- Find how many accounts there are for each customer. The output should include customer id and number of accounts for that customer. 4- Find the total balance amount of...

  • Database HW help!!!!!!! Provide the SQL statements for the following queries. (1) Provide the names and...

    Database HW help!!!!!!! Provide the SQL statements for the following queries. (1) Provide the names and phones of all swimmers currently in level (of id) 3. +-------+---------+---------------------------+ | FName | LName   | EMail                     | +-------+---------+---------------------------+ | Bobby | Khan    | theBKhan1 | | Clara | Johnson | ClaraJohnson_11 | +-------+---------+---------------------------+ 2 rows in set (0.00 sec) (2) Provide the names of swimmers who have signed up to participate in the event '100M Butterfly' of Meet id 1. +-------+---------+ | FName...

  • NEED THE SQL QUERIES ASAP PLEASE(LIKE 1 HOUR) THE ONES WITH ID ARE PRIMARY KEYS OR...

    NEED THE SQL QUERIES ASAP PLEASE(LIKE 1 HOUR) THE ONES WITH ID ARE PRIMARY KEYS OR FOREIGN etc Customer [ CustID, LastName, FirstName, Address, City, State, Zip, Phone, Fax, Email] Product [ ProdID, Description, Color, Size, Pack] Sales [ TransID, CustID, ProdID, Price, Quantity, Amount] Write SQL statement to produce a list of unique products and their prices from the Sales table. Please ensure that the products do not repeat. Write an SQL statement to list ProdID and Description for...

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

  • SQL Query Question: I have a database with the tables below, data has also been aded...

    SQL Query Question: I have a database with the tables below, data has also been aded into these tables, I have 2 tasks: 1. Add a column to a relational table POSITIONS to store information about the total number of skills needed by each advertised position. A name of the column is up to you. Assume that no more than 9 skills are needed for each position. Next, use a single UPDATE statement to set the values in the new...

  • Think about data collected and used by Netflix. (You may select more than one answer. Single...

    Think about data collected and used by Netflix. (You may select more than one answer. Single click the box with the question mark to produce a check mark for a correct answer and double click the box with the question mark to empty the box for a wrong answer. Any boxes left with a question mark will be automatically graded as incorrect.) Required: a. Identify three tables that would contain customer or subscription data. Customer table Cash receipt table Payment...

  • An online company sells hundreds of office supply products on its e-Commerce store. It has asked...

    An online company sells hundreds of office supply products on its e-Commerce store. It has asked you to design and implement a sales order processing system which will be used by users in our Operations department to process sales orders. Here is an overview of the sales order process. Customers make purchases by placing orders. Each customer has a customer number and profile (such as name, shipping address). To simplify the matter, each time an order is placed, only one...

  • Given the following schema: I would like to know the SQL queries to: 1. Total up...

    Given the following schema: I would like to know the SQL queries to: 1. Total up the number of checkouts made on each month of the year. Then print the month (spelled out completely) and the total number of corresponding checkouts next to it. That is, print "January" and total number of checkouts made in January, and so on. 2. Show the furniture styles that are checked-out on Sundays only. That is, none of the furniture in that style must...

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