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 |
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.
Please help I promise positive feedback Part IV. Formulate SQL queries that follow for the database...
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,...
Create a new database and execute the code below in SQL Server’s query window to create the database tables. CREATE TABLE PhysicianSpecialties (SpecialtyID integer, SpecialtyName varchar(50), CONSTRAINT PK_PhysicianSpecialties PRIMARY KEY (SpecialtyID)) go CREATE TABLE ZipCodes (ZipCode varchar(10), City varchar(50), State varchar(2), CONSTRAINT PK_ZipCodes PRIMARY KEY (ZipCode)) go CREATE TABLE PhysicianPractices (PracticeID integer, PracticeName varchar(50), Address_Line1 varchar(50), Address_Line2 varchar(50), ZipCode varchar(10), Phone varchar(14), Fax varchar(14), WebsiteURL varchar(50), CONSTRAINT PK_PhysicianPractices PRIMARY KEY (PracticeID), CONSTRAINT FK_PhysicianPractices_ZipCodes FOREIGN KEY (ZipCode) REFERENCES Zipcodes) go CREATE...
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...
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)...
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...
The following SQL DDL script creates a database for a social network application. create table userProfile( id char(10) primary key, firstName varchar(20), lastName varchar(20), dob date, email varchar(30) ); create table foaf( userid char(10), friendID char(10), timeEstablished date, constraint pk primary key(userid, friendID), constraint fk1 foreign key(userid) references userProfile(id), constraint fk2 foreign key(friendID) references userProfile(id) ); create table activity( actID char(20) primary key, topic varchar(20), description varchar(100), location varchar(20), ActivityDate date, hostUser char(10), foreign key(hostUser) references userProfile(id) ); create table...
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 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 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 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...