SQL HELP!! Question: Pictures of Database: Previous query: SELECT customer.c_nam
ID: 3830805 • Letter: S
Question
SQL HELP!!
Question:
Pictures of Database:
Previous query:
SELECT
customer.c_name,
customer.c_custkey,
count(o_orderKey) as count,
avg(orders.O_TOTALPRICE) as total_value,
min(orders.O_TOTALPRICE) as min_value,
max(orders.O_TOTALPRICE) as max_value
FROM customer INNER JOIN orders on orders.O_CUSTKEY = customer.c_custkey
group by customer.c_name, customer.c_custkey
order by customer.c_custkey, customer.c_name
Explanation / Answer
SELECT
'Customer#' || customer.c_name as Customer ,
customer.c_custkey as ID,
count(o_orderKey) as "Total Orders",
avg(orders.O_TOTALPRICE) as "Average Orders",
min(orders.O_TOTALPRICE) as "Min Order",
max(orders.O_TOTALPRICE) as "Max Order"
FROM customer INNER JOIN orders on orders.O_CUSTKEY = customer.c_custkey
group by customer.c_name, customer.c_custkey
order by customer.c_custkey, customer.c_name;
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.