Q:

Pivot and more with aggregation

Can any one help me how to write query for this. 
I have a table like this:
YR  MON SM  SG  SP  CUS NPS GWT    
2016    1   5   9   6543    9020418 47115.94    1
2016    2   5   9   6543    9020418 45010.28    1
2016    3   5   9   6543    9020418 91956.52    1
2016    4   5   9   6543    9020418 92003.14    1
2016    5   5   9   6543    9020418 109858.89   1
2016    6   5   9   6543    9020418 39979.23    -0.151471243
2016    7   5   9   6543    9020418 72114.07    0.602168882
2016    8   5   9   6543    9020418 70135.41    -0.237298127

and output looks like below. 
SM  SG  SP  CUS YEAR    JAN FEB MAR APR MAY JUN JUL AUG **FY**
5   9   6543    9020418 2016    47115.94    45010.28    91956.52    92003.14    109858.89   39979.23    72114.07    70135.41    568173.48

SM  SG  SP  CUS YEAR    JAN FEB MAR APR MAY JUN JUL AUG **FG**
5   9   6543    9020418 2016    1   1   1   1   1   -0.151471243    0.602168882 -0.237298127    0.651

Here FY is sum of NPS and FG is average of GWT. 

A:

You can try to solve it that way:
-- Create demo data
CREATE TABLE #temp(YR int,MON int,SM int,SG int,SP int,CUS int,NPS float,GWT float)

INSERT INTO #temp(YR,MON,SM,SG,SP,CUS,NPS,GWT)
VALUES  (2016,1,5,9,6543,9020418,47115.94,1),
        (2016,2,5,9,6543,9020418,45010.28,1),
        (2016,3,5,9,6543,9020418,91956.52,1),
        (2016,4,5,9,6543,9020418,92003.14,1),
        (2016,5,5,9,6543,9020418,109858.89,1),
        (2016,6,5,9,6543,9020418,39979.23,-0.151471243),
        (2016,7,5,9,6543,9020418,72114.07,0.602168882),
        (2016,8,5,9,6543,9020418,70135.41,-0.237298127)

-- Your Part
-- FY
SELECT pvt. YR, pvt.sm, pvt.sg, pvt.sp, pvt.cus, 
    pvt.[1] as jan, pvt.[2] as feb, pvt.[3] as mar, pvt.[4] as apr,
    pvt.[5] as may, pvt.[6] as jun, pvt.[7] as jul, pvt.[8] as aug,
    pvt.[9] as sep, pvt.[10] as oct, pvt.[11] as nov, pvt.[12] as [dec], pvt. FY
FROM (
    SELECT yr, mon, sm, sg, sp, cus, nps, SUM(nps) OVER(PARTITION BY yr) as FY
    FROM #temp
) as dat
PIVOT (
    SUM(NPS)
    FOR Mon IN([1],[2],[3],[4],[5],[6],[7],[8],[9],[10],[11],[12])
) as pvt

-- FG
SELECT pvt. YR, pvt.sm, pvt.sg, pvt.sp, pvt.cus, 
    pvt.[1] as jan, pvt.[2] as feb, pvt.[3] as mar, pvt.[4] as apr,
    pvt.[5] as may, pvt.[6] as jun, pvt.[7] as jul, pvt.[8] as aug,
    pvt.[9] as sep, pvt.[10] as oct, pvt.[11] as nov, pvt.[12] as [dec], pvt. FG
FROM (
    SELECT yr, mon, sm, sg, sp, cus, gwt, SUM(gwt) OVER(PARTITION BY yr) as FG
    FROM #temp
) as dat
PIVOT (
    AVG(GWT)
    FOR Mon IN([1],[2],[3],[4],[5],[6],[7],[8],[9],[10],[11],[12])
) as pvt

-- Clean up
DROP TABLE #temp

Beware, that this solution is designed for SQL Server as its unclear which DBMS you are using.