Answer..-
Step 1 : Create a table OrderNumber which has 3 columns ('OrderNo' 'CustomerNo' 'Food Name')
create table OrderNumber('OrderNo' INT NOT NULL PRIMARY KEY,
'CustomerNo' INT,
'Food Name' VARCHAR(25));
Step 2 : Create Another table Having Information about every customer.
create table Customer('CustomerNo' INT,
'Name' VARCHAR(25),
'Address' VARCHAR(25),
'PhoneNo' INT(10),
'E-mail ID' VARCHAR(50));
Step 3 : Enter Details in Table OrderNumber .
For Ex. , INSERT INTO OrderNumber VALUES(1,1,'Masala Dosa');
INSERT INTO OrderNumber VALUES(2,2,'Idli');
Step 4 : Enter Details in Table Customer.
For Ex. , INSERT INTO Customer VALUES(1,'Rajesh','Delhi', 1234567890,'xyz@abc.com' );
INSERT INTO Customer VALUES(2,'Mahesh','Amritsar', 9876541230,'pqr@abc.com' );
Step 5 : Enter the Details of all the customers as above
QUERY 1 : Determine that most popular food item ordered by all customers. (Display the food name and number of items it was ordered—sort the food name in ascending order).
ANSWER: SELECT Food_Name,COUNT(*)
FROM OrderNumber
GROUP BY Food_Name
ORDER BY Food_Name ASC;
QUERY 2 : Which customer visited the restaurant the most. (Display the customer’s name, address, phone and email address).
ANSWER: SELECT *
FROM Customer
WHERE CustomerNo IN (SELECT DISTINCT CustomerNo
FROM OrderNumber
GROUP BY CustomerNo
ORDER BY Count(*)
DESC LIMIT 1);
QUERY 3: Smith would like you to include one query that uses the average function. You get to elect how this query is implemented but ensure that the OrderNumber table is used.
ANSWER: As OrderNumber Table does not contain a column for which calculation of average makes any sense but for only to show how Average(AVG) function is used in database I have calculated the average of OrderNo (which does not any sense). So the Query is as follows -
SELECT AVG(CustomerNo) FROM OrderNumber;
*Part II:Smith has decided to track customers and what s/he is orderingthe most. In order to...
a) Determine the order-ID and the total price of each
order.(Note that the total price of an order is the price for the
ordered products on the day of the order plus the price of the
selected shipping.)
Note. The requested query is quite complicated(and long). The
main problem is that you have to determine the price of the ordered
products at the day of the order. Recall that the price table
stores the price of a product starting at...
Exercise 3 [12.5 marks] Given the Restaurant management system database that contains the following tables (primary keys are underlined and foreign keys are preceded with #): Customer (customerID,customerFirstName,customerLastName,customerAddress) Oreder (orderID,orderDate, #customerID,#menuItemID,#staffID) MenuItem(menuItemID, menuItemName,ingredients,type,availability) Staff(staffID, staffName, staffPhoneNumber, staffRole ) OrderPayment(paymentID,paymentAmount,#orderID,#staffID) 1) Without using DISTINCT, write the SQL query equivalent to the following one:[1.5 marks] SELECT DISTINCT menuItemName FROM MenuItem WHERE type = ‘Vegetarian’ OR availability= ‘Yes’; 2) Express the following queries in SQL: a) Find the number of orders placed by...
You will develop an E-Commerce database used to maintain
customers, products and sales information. You are required to 1)
gather and analyze requirements 2) design logical structure of the
database 3) create stored procedures to develop the tables and
insert the data 4) write SQL statements for data extraction and
reporting.
Throughout the course of this semester you have analyzed the
requirements for an eCommerce database, designed and developed your
database. As a class we have gone through the process...
Write a SQL query that shows the price of each
order made by customers whose last name starts with the
letter M. Display the order number, the last name on the order, and
the price of the order (Order Price). Show the results with the
highest order price first.
Write a SQL query that determines the most
expensive item purchased in each order (Item Price). Display the
order number, the date of the order, the last name of the customer...
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,...
Customer Transaction Table – CUSTOMER_TXNS Column Name Description Type Account_id Account identifier Integer Txn_timestamp Time of transaction (UTC) Timestamp Product_id The id of the product purchased Integer Txn_Amt The revenue amount of the transaction Float Txn_Qty The number of items purchased Integer NOTE: Customer Transaction table has multiple records per account_id. Customer Master Table – CUSTOMER_MSTR Column Name Description Type Account_id Account identifier Integer Country Country Code Character(3) Address Address of the customer Character(64) Registerd_Dt Date the account id was...
SQL Queries – in this assignment you will be asked to create several SQL queries relating to the Sakila database that we installed in class. You may freely use DBeaver to create these queries, but I will expect your solution to show me the SQL code to answer or complete the tasks below. Write a query that produces the last name, first name, address, district, and phone number for every customer in the customer table. (You don’t need to include...
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...
The Case Express Delivery (ED) is a Morgantown based home goods company. Customers can call in orders and ED mails the items to the customer. They also email the customers a bill, as seen below. Customers can mail in a check, once they receive the order. ED needs to track whether the order has been paid or not, but the payment information is handled by a third-party vendor. ED needs to create a database to track their customers. Each customer...
Computer science help! A software company sells their software packages for $99.00 each. They would like you to write a program that will calculate and display an invoice for their customers. Quantity discounts are given according to the following table: Quantity Discount 1 - 9 No discount 10 – 19 20% 20 – 49 30% 50 - 99 40% 100 or more 50% Write a C++ program that asks for the customer’s name and the number of software packages sold...