Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9104391
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T01:51:26+00:00 2026-06-17T01:51:26+00:00

I have two tables that I need to create a query for. I’m sure

  • 0

I have two tables that I need to create a query for. I’m sure I’ll need to join them as well.

I need to take the CustomerName and Address of customer from my Customer table but I also need the query to show the total dollar amount of all the orders placed by customer. So if the customer spent for example $300 dollars this year in total, that $300 is the output I’m trying to achieve.

I have a table called Order Details that uses an OrderID which is tied to a CustomerID and there are unitprice and quantity columns in the Order Details table. I’m trying to figure out how to multiple these but I am going crazy.

I have tried this to get at least the total from the orders but I have syntax errors for sure:

SELECT unitprice, 
       quantity 
FROM   [Order details] (unitprice * quantity) AS Totalorders, 
       from [Order Details] 
WHERE  orderid > 0 

also this without any luck :

SELECT customers.companyname                                AS 'Company Name', 
       customers.address                                    AS 'Address', 
       [order details].unitprice * [order details].quantity AS 'Orders' 
FROM   customers 
       LEFT JOIN orders 
              ON customers.customerid = orders.customerid 
ORDER  BY customers.companyname, 
          customers.address, 
          orders 

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T01:51:27+00:00Added an answer on June 17, 2026 at 1:51 am

    You need to join in the order details and do a group by aggregation:

    SELECT c.CompanyName AS "Company Name",
           c.Address AS "Address",
           sum(od.Unitprice * od.quantity) as "Orders"
    FROM Customers c LEFT JOIN
         Orders o
         ON c.CustomerID = o.CustomerID left join
         [Order Details] od
         on od.orderid = o.orderid
    GROUP BY c.CompanyName, c.Address
    ORDER BY c.CompanyName, c.Address
    

    In addition, I made some stylistic changes. I added aliases to the table names. I find it much easier to read c.CompanyName rather than Customers.CompanyName. I changed the delimiter on the column aliases to use double quotes rather than single quotes. I associate single quotes with string constants inside the statement.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables described below. What I need is a single query that
I have two tables with some ID's and I need a query that returns
I have a two tables that are Subject and chapter . I need to
I have a database two tables and a linking table that I need a
I have two tables that I want to join together. Table1 Year, ID, Theme,
I have two tables that I am joining with the following query... select *
I have two tables that I'm trying to create a relationship between so I
I need to create a query to combine the data from two tables, I
I have two tables I need to create an average sum from... Caravan Category
I need to execute a query that joins two tables, groups by a value,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.