I have two tables that I am joining together with several where clauses. However the table I am trying to join has several million rows of data. I want to find the the most recent readdate for each premnum from the pm_dmd_hist table.
My Current SQL Code is:
INNER JOIN pm_premise
ON pm_dmd_Hist.premnum = pm_premise.premnum
WHERE PM_PREMISE.DIVISION_CODE = Any ('PSCO', 'DM', 'No', 'SE', 'SW', 'BD', 'NR', 'HL', 'HP', 'WD', 'FR', 'MD', 'PD', 'SV', 'UD')
AND PM_DMD_HIST.TARIFFCLASS = (6037)
AND PM_DMD_HIST.BILLED_DMD < 11
and PM_DMD_HIST.READDATE > '01-JAN-17'
Order BY readdate asc;