                     d.out_transaction_id,
                     d.disposed_shares,
                     d.disposed
-                   FROM (disposals d
-                     JOIN transactions tout ON (((d.out_transaction_id = tout.transaction_id) AND (date_part('year'::text, tout.date) = date_part('year'::text, ('now'::text)::date)))))
+                   FROM ((disposals d
+                     JOIN transactions tout ON ((d.out_transaction_id = tout.transaction_id)))
+                     JOIN annual_range ar_1 ON (((ar_1.range @> tout.date) AND (ar_1.year = (date_part('year'::text, ('now'::text)::date))::smallint))))
                 ), annual_transactions AS (
                  SELECT annual_disposals.in_transaction_id AS transaction_id
                    FROM annual_disposals

    SFUNC = agg_first,
    STYPE = anyarray,
    INITCOND = '{}'
);





--
-- Name: annual_range_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY annual_range
    ADD CONSTRAINT annual_range_pkey PRIMARY KEY (year);


--
-- Name: disposals_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

