I have 3 date params.
@Now
@MonthFrom
@YearFrom
What is the best practice?
1.) do my count as a sub query ie:
, (select count(sale_id) from sale where date >= @MonthFrom and date <= @Now) as 'MTD'
, (select count(sale_id) from sale where date >= @YearFrom and date <= @Now) as 'YTD'
or:
2.) Use Joins Ie:
, sum(SMTD.SaleID) as 'MTD'
, Sum(SYTD.SaleID) as 'YTD'
inner join sale SMTD (NoLock)
on (join creteria) and @MonthFrom and date <= @Now
inner join Sale SYTD (NoLock)
on (join creteria) and @YearFrom and date <= @Now