Hi elvisidrizi1,
First insert the result in a Temporary table. Then use UNION to add row with total from the Temporary table data.
Refer below query.
Database
For this example I have used of Northwind database that you can download using the link given below.
Download Northwind Database
SQL
SELECT TOP 3 SUM(Freight) AS total,
FORMAT(OrderDate, 'ddd', 'en-us') AS 'day',
SUM(CONVERT(INT, CONVERT(VARCHAR(MAX),ShipVia))) AS 'quantity',
ShipName AS 'user',
ShipAddress AS 'desc'
INTO #Temp
FROM dbo.Orders
WHERE FORMAT(OrderDate, 'ddd', 'en-us') = 'Fri'
GROUP BY FORMAT(OrderDate, 'ddd', 'en-us'), ShipName, ShipAddress
SELECT [total],[day],[quantity],[user],[desc]
FROM #Temp
UNION
SELECT SUM([total]),'','','','' FROM #Temp
DROP TABLE #Temp
Output
total |
day |
quantity |
user |
desc |
7.48 |
Fri |
3 |
Lazy K Kountry Store |
12 Orchestra Terrace |
287.38 |
Fri |
7 |
La maison d'Asie |
1 rue Alsace-Lorraine |
764.6 |
Fri |
13 |
White Clover Markets |
1029 - 12th Ave. S. |
1059.46 |
|
0 |
|
|