QUERY PLAN
GroupAggregate (cost=11.78..11.86 rows=1 width=92)
Group Key: (CASE WHEN (bargain_date >= ((to_char((bargain_date)::timestamp with time zone, 'YYYY-'::text) || '01-01'::text))::date) THEN (to_char((bargain_date)::timestamp with time zone, 'YYYY'::text))::integer ELSE ((to_char((bargain_date)::timestamp with time zone, 'YYYY'::text))::integer - 1) END)
-> Sort (cost=11.78..11.79 rows=1 width=26)
Sort Key: (CASE WHEN (bargain_date >= ((to_char((bargain_date)::timestamp with time zone, 'YYYY-'::text) || '01-01'::text))::date) THEN (to_char((bargain_date)::timestamp with time zone, 'YYYY'::text))::integer ELSE ((to_char((bargain_date)::timestamp with time zone, 'YYYY'::text))::integer - 1) END)
-> Bitmap Heap Scan on tbl_projects p (cost=4.30..11.77 rows=1 width=26)
Recheck Cond: (client_id = 3296)
Filter: ((bargain_date IS NOT NULL) AND (project_status = 3))
-> Bitmap Index Scan on tbl_projects_client_id_idx (cost=0.00..4.29 rows=2 width=0)
Index Cond: (client_id = 3296)