1252748
1252748

Reputation: 15379

Add up values from table columns in SQL

Is it possible in PostgreSQL to select one column from a table within a particular date span (there is a date column) and - here is the catch! - add the table together. Like for making a sales report?

Upvotes: 0

Views: 145

Answers (2)

Taryn
Taryn

Reputation: 247860

Based on your comment, I think you are referring to SUM(). This is an aggregate function

SELECT SUM(amount)
FROM sales_orders 
WHERE date BETWEEN '2011-03-06' and '2011-04-06' -- not sure what your date is.

Upvotes: 1

D'Arcy Rittich
D'Arcy Rittich

Reputation: 171559

If I understand you correctly, you are looking for this:

SELECT sum(amount) 
FROM sales_orders 
WHERE date ...

Upvotes: 0

Related Questions