SQL Mangement Studio / SQL: View GroupBy / Sum aggregate functions

Quite new to this, but I created a SQL script that groups and assigns a column .., but in SQL Management studio it shows me a grid with a column value, but nothing below it, i.e. SUM ..

I need to set up SQL management studio to show me SUM or something like that.

Here is my request is very simple

    SELECT  RowNum ,
    ClientName ,
    ( SELECT    SUM(Amount) AS Expr1
    ) AS Amount
    FROM    #TempItems
    GROUP BY RowNum , Amount , ClientName

I also modified it to display a TextView, not GRIDVIEW, but there is still no hope.

It displays the Amount column correctly, but I do not see the SUM under it

Any help really appreciated

+3
source share
2 answers

You do not need a subquery:

SELECT
    RowNum ,
    ClientName ,
    SUM(Amount) AS Amount
FROM #TempItems
GROUP BY RowNum, ClientName
+3
source

... - WITH WITH ROLLUP:

SELECT
    RowNum ,
    ClientName ,
    SUM(Amount) AS Amount
FROM #TempItems
GROUP BY RowNum, ClientName WITH ROLLUP

NULL .

0

Source: https://habr.com/ru/post/1775645/


All Articles