Write a SELECT statement that returns one row for each customer that has orders with these columns: The email_address from the Customers table A count of the number of orders The total amount for each order (Hint: First, subtract the discount amount from the price. Then, multiply by the quantity.) Return only those rows where the customer has more than 1 order. Sort the result set in descending sequence by the sum of the line item amounts.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
  1. Write a SELECT statement that returns one row for each customer that has orders with these columns:

The email_address from the Customers table

A count of the number of orders

The total amount for each order (Hint: First, subtract the discount amount from the price. Then, multiply by the quantity.)

Return only those rows where the customer has more than 1 order.

Sort the result set in descending sequence by the sum of the line item amounts.

 

 

everytime l try to write this sql statement an error occurs

Oracle SQL Developer : C:\Users\tafad\Desktop\semester 3\adv database\assignment1\mgs.sql
File Edit View Navigate Run Source Team Tools Window Help
66
Connections
e Connections
X
gs
Tables (Filtered)
ADDRESSES
ADMINISTRATORS
CATEGORIES
CUSTOMERS
ORDER_ITEMS
ORDERS
ORDER_ID
CUSTOMER_ID
ORDER_DATE
SHIP_AMOUNT
TAX_AMOUNT
SHIP_DATE
SHIP_ADDRESS_ID
CARD_TYPE
CARD_NUMBER
CARD_EXPIRES
BILLING_ADDRESS_ID
PRODUCTS
PRODUCT_ID
CATEGORY_ID
PRODUCT_CODE
PRODUCT_NAME
DESCRIPTION
LIST_PRICE
DISCOUNT_PERCENT
DATE_ADDED
Views
Indexes
Packages
Procedures
Functions
Operators
Queues
Queues Tables
Triggers
Colab 1.sql
SOL
SQL Worksheet History
6
7
8
SOL
Worksheet Query Builder
3
---QUESTION 1---
4
SELECT email address, COUNT(*) AS num orders, SUM(quantity*(price-discount)) AS total amount
FROM Customers c
5
create_mgs_user.sql x create_mgs_tables.sql x mgs.sql
JOIN Orders o ON c.customer_id = o.customer_id
JOIN Order_Items oi ON o.order_id = oi.order_id
GROUP BY email_address
9
10
11
12
13
14 ---QUESTION 2---
15
16
HAVING num_orders > 1
ORDER BY total amount DESC;
17--QUESTION 3----
SOL
18
19 --QUESTION 4--
20
SELECT DISTINCT category_name
Messages - Log
21 FROM categories c
22 WHERE c.category_id IN
(SELECT category_id
24
FROM products)
25 ORDER BY category_name;
26
Messages
27
--QUESTION 5----
28 SELECT product_name, list_price
29 FROM products
Logging Page Statements *
| Line 4 Column 93
| Insert
T
mgs
X
0
| Modified | Windows: CF
Transcribed Image Text:Oracle SQL Developer : C:\Users\tafad\Desktop\semester 3\adv database\assignment1\mgs.sql File Edit View Navigate Run Source Team Tools Window Help 66 Connections e Connections X gs Tables (Filtered) ADDRESSES ADMINISTRATORS CATEGORIES CUSTOMERS ORDER_ITEMS ORDERS ORDER_ID CUSTOMER_ID ORDER_DATE SHIP_AMOUNT TAX_AMOUNT SHIP_DATE SHIP_ADDRESS_ID CARD_TYPE CARD_NUMBER CARD_EXPIRES BILLING_ADDRESS_ID PRODUCTS PRODUCT_ID CATEGORY_ID PRODUCT_CODE PRODUCT_NAME DESCRIPTION LIST_PRICE DISCOUNT_PERCENT DATE_ADDED Views Indexes Packages Procedures Functions Operators Queues Queues Tables Triggers Colab 1.sql SOL SQL Worksheet History 6 7 8 SOL Worksheet Query Builder 3 ---QUESTION 1--- 4 SELECT email address, COUNT(*) AS num orders, SUM(quantity*(price-discount)) AS total amount FROM Customers c 5 create_mgs_user.sql x create_mgs_tables.sql x mgs.sql JOIN Orders o ON c.customer_id = o.customer_id JOIN Order_Items oi ON o.order_id = oi.order_id GROUP BY email_address 9 10 11 12 13 14 ---QUESTION 2--- 15 16 HAVING num_orders > 1 ORDER BY total amount DESC; 17--QUESTION 3---- SOL 18 19 --QUESTION 4-- 20 SELECT DISTINCT category_name Messages - Log 21 FROM categories c 22 WHERE c.category_id IN (SELECT category_id 24 FROM products) 25 ORDER BY category_name; 26 Messages 27 --QUESTION 5---- 28 SELECT product_name, list_price 29 FROM products Logging Page Statements * | Line 4 Column 93 | Insert T mgs X 0 | Modified | Windows: CF
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Table
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education