I need to get sales comparison between two reporting periods. It should display sales which only have decreased than previous year. I tried below query to get values.But how can I add aggregate function in where clause.
SELECT
CardCode,
CardName,
Sum(case when Year(DocDate)='2018' then DocTotal else 0 end) as Sold2018,
Sum(case when Year(DocDate)='2019' then DocTotal else 0 end) as Sold2019
FROM
ORDR
***where Sold2018 < Sold2019***
Group By
CardCode,
CardName