I have this query (with some help from mr Erwin Brandstetter), which prints week intervals.
SELECT to_char(d.day, 'YYYY/MM/DD - ') || to_char(d.day + 6, 'YYYY/MM/DD') AS week
FROM (
SELECT day::date
FROM generate_series('2014-08-01'::date, '2014-09-14'::date, interval '1 week') day
) d
JOIN account_details a ON a.date_opened >= d.day
AND a.date_opened < d.day + 6
GROUP BY d.day;
But I want to append and sum other info depending on the value in a specific column
This should be the end result.

So the info for activated and declined comes from one string column situation.
I tried to capture a regexp_matches match value from the column and sum the amount of captures (bellow), but it did not do the trick.
Please, how would you go about capturing and summing string values from one column?
SELECT to_char(d.day, 'YYYY/MM/DD - ') || to_char(d.day + 6, 'YYYY/MM/DD') AS week
, SUM(SELECT regexp_matches(situation, 'active')) AS activated
, SUM(SELECT regexp_matches(situation, 'declined')) AS declined
FROM (
SELECT day::date
FROM generate_series('2014-08-01'::date, '2014-09-14'::date, interval '1 week') day
) d
JOIN account_details a ON a.date_opened >= d.day
AND a.date_opened < d.day + 6
GROUP BY d.day;
SAMPLE DATA
So there is quite a lot more columns, but the only two will be used here. open_date and situation
situation also has quite a few different options, but only Active and Declined will be used
occurrencesormatches. No idea, this is my second day using Postgres so Im trying to learn, but the docs is not all THAT clear.