I'm trying to display some records which meet some certain criteria.
That works fine, but I also want to retrieve the total amount of orders. These are all located in the field 'Amount' from the Orders table.

So if record 1 has got '22' in it's amount field, and record 5 has got '55' in it's amount field.. the total should be 77.

My sql coding looks like this:

SELECT Orders.OrderID, Customers.CustomerName, Orders.OrderDate, sum(Orders.Amount) as total
FROM Orders 
INNER JOIN Customers
ON Orders.CustomerID=Customers.CustomerID
where customers.country='Germany'  
order by Orders.Orderdate

But it only retrieves 1 record (due to the summage), when I remove the sum part it retrieves all records.

How can I retrieve all records, as well as the summage ?

Edited by pritaeas: Added markdown.

4 Years
Discussion Span
Last Post by balaji9124
SELECT SUM(value) as total FROM table;


Edited by pritaeas: Added markdown.


If you wanna retrieve the total number of recs then you may try using the aggregate function count in your query.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.