Home Forums SQL Server 2008 T-SQL (SS2K8) Need some help in solving the below logic of averages RE: Need some help in solving the below logic of averages

  • Is this what you're looking for?

    SELECT t2.[index], t1.[type], t1.code, AVG([current]) avg_current, AVG([bpo]) avg_bpo, AVG([forecast]) avg_forecast

    FROM table1 t1

    INNER JOIN table2 t2 ON t2.code = t1.code

    GROUP BY t2.[index], t1.[type], t1.code

    ORDER BY t2.[index], t1.[type], t1.code;