I was hoping to eliminate this part of the query:
(cast(extract( YEAR FROM m.taken ) + greatest( -1 *
sign(
(extract( YEAR FROM m.taken )||'-12-31')::date -
(extract( YEAR FROM m.taken )||'-01-01')::date ), 0
) AS text)||'-12-31')::date
That uses functions to create the dates, which is definitely the problem.
I'd still have the query return all the results for both data sets. If
providing the query with two data sets won't work, what will?
Dave