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].

A Guide to SQL
9th Edition
ISBN:9781111527273
Author:Philip J. Pratt
Publisher:Philip J. Pratt
Chapter2: Database Design Fundamentals
Section: Chapter Questions
Problem 3TD
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
A Guide to SQL
A Guide to SQL
Computer Science
ISBN:
9781111527273
Author:
Philip J. Pratt
Publisher:
Course Technology Ptr
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781305627482
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781285196145
Author:
Steven, Steven Morris, Carlos Coronel, Carlos, Coronel, Carlos; Morris, Carlos Coronel and Steven Morris, Carlos Coronel; Steven Morris, Steven Morris; Carlos Coronel
Publisher:
Cengage Learning
Principles of Information Systems (MindTap Course…
Principles of Information Systems (MindTap Course…
Computer Science
ISBN:
9781305971776
Author:
Ralph Stair, George Reynolds
Publisher:
Cengage Learning
Oracle 12c: SQL
Oracle 12c: SQL
Computer Science
ISBN:
9781305251038
Author:
Joan Casteel
Publisher:
Cengage Learning
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning