Home > Net >  How to sum a column from a query created table
How to sum a column from a query created table

Time:04-27

I created a SELECT query, after I execute it, it shows me a new table as I wanted (you can see it in the screenshot).

The problem is that I'm trying to add a new line to the query which supposes to sum() the column "Price" in the table that I got from the query

SELECT SUM(PRICE) AS totalPay 
FROM Meals 

You can see the tables here, and also the queries that worked at that, didn't.

I want it to be like that:

Like this

CodePudding user response:

Just add the SUM(price) as new field in your first SELECT. SELECT SUM(Meals.Price) as 'TotalPay', tableN01.waiterID FROM tableN01 INNER JOIN Meals etc.

  •  Tags:  
  • sql
  • Related