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?
2 Answers
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.
7 Comments
1252748
oops..meant to post this comment to you : razorsql asked me to enter a parameter value for & ..what does that mean?
Taryn
@thomas you need to use
AND between your dates not &.Taryn
@thomas you need to place you dates in the correct format
yyyy-mm-ddErwin Brandstetter
Please link to the current version of the manual. Postgres 8.1 has been out of business for quite a while now. If you don't need to address a particular version, it's probably best to point to
http://www.postgresql.org/docs/current/interactive/.Taryn
@ErwinBrandstetter agreed. That was the link I got when I tried to find aggregate function. I should have verified it was functioning when I posted. Thanks for the edit.
|
If I understand you correctly, you are looking for this:
SELECT sum(amount)
FROM sales_orders
WHERE date ...
1 Comment
1252748
my razorsql asked me to enter a parameter value for & ..what does that mean?
SELECT amount FROM sales_orders WHERE date BETWEEN 11-03-06 & 11--04-06and add them together...INSERT INTO tbl_a SELECT date_fld FROM tbl_b WHERE CAST(date_fld AS DATE) BETWEEN '2012-01-01' AND '2012-01-31'but it sounds you may want a join?