Home Forums SQL Server 2012 SQL Server 2012 - T-SQL Trying to find a more simplistic way to execute this complicated Aggregation Query RE: Trying to find a more simplistic way to execute this complicated Aggregation Query

  • You say "..of average revenue by account... " so why are you averaging it based on fiscalyear.

    Sum(revenue)/count(distinct fiscalyear) AvgByAccount

    You could easily replace it with the Average function AVG(revenue) which will average it grouped on SalesID,AccountID and FiscalMonth

    --------------------------------------------------------------------------------------------------
    I am just an another naive wannabe DBA trying to learn SQL Server