mber in descending order and then by invoice date in ascending order. Here you will use an aggregate SUM(x,y) function in your SELECT clause to calculate the total dollar amount (a calculated field – name it TOTAL). Don’t forget to join on the tables as well. [hint: you should have 8 rows of output ordered properly].

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
icon
Concept explainers
Question

SQL:

For every invoice, display the invoice number, invoice date and the total dollar amount for all products purchased in the invoice, ordered by invoice number in descending order and then by invoice date in ascending order. Here you will use an aggregate SUM(x,y) function in your SELECT clause to calculate the total dollar amount (a calculated field – name it TOTAL). Don’t forget to join on the tables as well. [hint: you should have 8 rows of output ordered properly].

 

select inv_number, inv_date sum(list_price) as 'total' from invoice, line order by desc inv_num, asc inv_date.

I am getting the error:

ORA-00923: FROM keyword not found where expected  

Am I formulating the query incorrectly? 

### Entity-Relationship Diagram (ERD) Explanation

This diagram represents an Entity-Relationship Diagram (ERD) for a sample business database. The ERD visually describes the various entities (tables), their attributes (fields), and the relationships between them. This is crucial for understanding how data is structured and stored in a relational database.

#### Entities and Their Attributes

1. **CUSTOMER**
   - **CUS_CODE**: Customer Code (Primary Key)
   - **CUS_LNAME**: Customer Last Name
   - **CUS_FNAME**: Customer First Name
   - **CUS_INITIAL**: Customer Initial
   - **CUS_AREACODE**: Customer Area Code
   - **CUS_PHONE**: Customer Phone Number
   - **CUS_BALANCE**: Customer Balance
   
2. **INVOICE**
   - **INV_NUMBER**: Invoice Number (Primary Key)
   - **CUS_CODE**: Customer Code (Foreign Key referencing CUSTOMER)
   - **INV_DATE**: Invoice Date

3. **LINE**
   - **INV_NUMBER**: Invoice Number (Foreign Key referencing INVOICE)
   - **LINE_NUMBER**: Line Number (Primary Key)
   - **P_CODE**: Product Code (Foreign Key referencing PRODUCT)
   - **LINE_UNITS**: Line Units
   - **LINE_PRICE**: Line Price
   
4. **PRODUCT**
   - **P_CODE**: Product Code (Primary Key)
   - **P_DESCRIPT**: Product Description
   - **P_INDATE**: Product In-Date
   - **P_QOH**: Product Quantity On Hand
   - **P_MIN**: Product Minimum
   - **P_PRICE**: Product Price
   - **P_DISCOUNT**: Product Discount
   - **V_CODE**: Vendor Code (Foreign Key referencing VENDOR)
   
5. **VENDOR**
   - **V_CODE**: Vendor Code (Primary Key)
   - **V_NAME**: Vendor Name
   - **V_CONTACT**: Vendor Contact
   - **V_AREACODE**: Vendor Area Code
   - **V_PHONE**: Vendor Phone Number
   - **V_STATE**: Vendor State
   - **V_ORDER**: Vendor Order
   
6. **EMPLOYEE**
   - **EMP_NUM**: Employee Number (Primary Key)
   - **EMP_TITLE**: Employee Title
   - **EMP_LNAME**: Employee
Transcribed Image Text:### Entity-Relationship Diagram (ERD) Explanation This diagram represents an Entity-Relationship Diagram (ERD) for a sample business database. The ERD visually describes the various entities (tables), their attributes (fields), and the relationships between them. This is crucial for understanding how data is structured and stored in a relational database. #### Entities and Their Attributes 1. **CUSTOMER** - **CUS_CODE**: Customer Code (Primary Key) - **CUS_LNAME**: Customer Last Name - **CUS_FNAME**: Customer First Name - **CUS_INITIAL**: Customer Initial - **CUS_AREACODE**: Customer Area Code - **CUS_PHONE**: Customer Phone Number - **CUS_BALANCE**: Customer Balance 2. **INVOICE** - **INV_NUMBER**: Invoice Number (Primary Key) - **CUS_CODE**: Customer Code (Foreign Key referencing CUSTOMER) - **INV_DATE**: Invoice Date 3. **LINE** - **INV_NUMBER**: Invoice Number (Foreign Key referencing INVOICE) - **LINE_NUMBER**: Line Number (Primary Key) - **P_CODE**: Product Code (Foreign Key referencing PRODUCT) - **LINE_UNITS**: Line Units - **LINE_PRICE**: Line Price 4. **PRODUCT** - **P_CODE**: Product Code (Primary Key) - **P_DESCRIPT**: Product Description - **P_INDATE**: Product In-Date - **P_QOH**: Product Quantity On Hand - **P_MIN**: Product Minimum - **P_PRICE**: Product Price - **P_DISCOUNT**: Product Discount - **V_CODE**: Vendor Code (Foreign Key referencing VENDOR) 5. **VENDOR** - **V_CODE**: Vendor Code (Primary Key) - **V_NAME**: Vendor Name - **V_CONTACT**: Vendor Contact - **V_AREACODE**: Vendor Area Code - **V_PHONE**: Vendor Phone Number - **V_STATE**: Vendor State - **V_ORDER**: Vendor Order 6. **EMPLOYEE** - **EMP_NUM**: Employee Number (Primary Key) - **EMP_TITLE**: Employee Title - **EMP_LNAME**: Employee
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Query Syntax
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