none
(Sumber: milist DOTNET) Sum Data RRS feed

  • Pertanyaan

  • salam,
    mau nanya dikit nih, saya ada data contohnya seperti ini :
    Nota     kode        nama      qty    harsat    total  grand_total
    x1        1              aaa          1     500        500   1500
    x1        2              bbb          1     1000      1000   1500
    x2        1              aaa          3     500        1500   2500
    x2        2              bbb          1     1000      1000   2500
    x3        1              aaa          1     500        500   1500
    x3        2              bbb          1     1000      500   1500
    saya ingin menjumlahkan grand total nya saja dari data tersebut berapa nilainya
    1500 + 2500 + 1500 =5500 (total) gimana ya?


    Agnes Sannie [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Rabu, 18 April 2012 08.36
    Moderator

Jawaban

  • Anda coba seperti ini:

    SELECT 

            SUM(s.[grand_total])

    FROM

    (

            SELECT 

                    t.[grand_total]

            FROM 

                    [dbo].[TableName] AS t

            GROUP BY 

                    t.[Nota], 

                    t.[GrandTotal]

    ) AS s

    Dijawab oleh: dede


    Agnes Sannie [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Rabu, 18 April 2012 08.37
    Moderator