List each category, the name of the customer who has spent the most on items in that category, and the total amount of money that customer spent in that category.please give me an sql query for this question and i have tables as follows customer(customer_name,address,zipcode,customer_id,state),office_supplies(item_name,item_id,cost,category),orders(order_id,date,customer_id) order_details(quantity,order_id,item_id)
List each category, the name of the customer who has spent the most on items in that category, and the total amount of money that customer spent in that category.please give me an sql query for this question and i have tables as follows
customer(customer_name,address,zipcode,customer_id,state),office_supplies(item_name,item_id,cost,category),
orders(order_id,date,customer_id) order_details(quantity,order_id,item_id)
Query
select category, customer_name, cost * quantity as
total_amount
from office_supplies
inner join customer on orders.customer_id =
customer.customer_id
inner join order_details on order_details.item_id =
office_supplies.item_id
group by category
having max(cost);
Explanation:
inner join -> retrieves data by combining more than one table
using the primary key and foreign key from more than tables
group by - sort the table by column given in it
having - get data from the table with the condition given in the having.
List each category, the name of the customer who has spent the most on items in that category, and the total amount of money that customer spent in that category.please give me an sql query for this q...
List all items sold by the company, sorted alphabetically by category and the alphabetically by item name. please give me an sql query for this question and i have tables as follows customer(customer_name,address,zipcode,customer_id,state),office_supplies(item_name,item_id,cost,category),orders(order_id,date,customer_id) order_details(quantity,order_id,item_id)
List the names of the customer (or customers) who spent the greatest dollar amount in a single order.please give me an sql query for this question and i have tables as follows customer(customer_name,address,zipcode,customer_id,state),office_supplies(item_name,item_id,cost,category),orders(order_id,date,customer_id) order_details(quantity,order_id,item_id)
List the names of all customers who bought both envelopes and labels (either in the same order or different orders).please give me an sql query for this question and i have tables as follows customer(customer_name,address,zipcode,customer_id,state),office_supplies(item_name,item_id,cost,category),orders(order_id,date,customer_id) order_details(quantity,order_id,item_id)
List all customers who bought copy paper but did not buy any other item.please give me an sql query for this question and i have tables as follows customer(customer_name,address,zipcode,customer_id,state),office_supplies(item_name,item_id,cost,category),orders(order_id,date,customer_id) order_details(quantity,order_id,item_id)
Using the below Relational Design from Oracle SQL data modeler,
provide sql script for the following queries (note please be sure
to include "PART3.Table_name" when pulling info from specific
tables)
Query 6: How many orders are there by customer and what is the
total sales and total profit sorted by customer’s total number of
orders?
Query 15: What is the total number of orders by shipping
class?
Query16: What are the monthly total sales from 2013 to 2014?
Query 17:...
CUSTTYPE (TID, TypeDesc) CUSTOMER (CID, Lname, Fname, TID, Address, ZIPcode) CUSTORDER (OrderNo, OrderDate, PromiseDate, ShippedDate, ShippingTerm, SalesID, CID) SALESREP (SalesID, Name, Phone, Address, ZIPcode, RepType) ORDERLINE (OrderNo, PID, Qty, Qty_RETD) FTSALESREP (SalesID, MonthPay, Rank) PTSALESREP (SalesID, HourlyRate, WeekHours) ZIP_TABLE (ZIPcode, City, State) VENDOR (VID, Name, Phone ZIPcode) PRODUCT (PID, CateID, ProdName, ProdFinish, Price, Qty_on_Hand, Description, VID) CATEGORY (CateID, CateType) Local View #1: Use three base tables to develop a SQL statement that will list the following information for a customer,...
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...
Please help me to solve Please, No handwriting COURSE; introduction to database Q- write a query SQL by Using the info below A. Normalize the Tables (in 3NF at least) B. Create the Normalized Tables and Populate them with at least 5 Rows C. Write the Wholesale Management System requested Queries & Execute them VERY IMPORTANT Screenshots from MySQL (or any other software you use) of all the tables after queries result. - Database system for a Wholesale Management System...
(TCO 6) Write a query to list the customer first name, last name as a single field with a heading of Customer along with the balance sorted by balance from lowest to highest. SalesRep Customer PK ReplD PK varchar(20) varchar(20) decimal(10,2) CustomerID int -OH Last Name FirstName Last Name varchar(20) Commission Rate FirstName varchar(20) Street varchar(20) City varchar(20) Order State char(2) Zipcode char(5) HO. ---OPK OrderID Balance decimal(10,2) ReplD int FK1 CustomeriD OrderDate ShipDate Part int int date date PK...
3. Create a query that will show how much money was spent by those people living in Clinton Township. Include in your output the first and last name as one column, the subtotal of what they spent, the sales tax and the grand total. Make sure you round your sales tax to 2 decimals. Order your output by the customer last name. My output looked like the following (I shortened my money columns due to page size. You do not...