---
title: "Is it possible to calculate the sum of each group in a table without using group by clause in SQL Server?"  
description: "Is it possible to calculate the sum of each group in a table without using group by clause in SQL Server?"  
author: "Anonymous User"  
published: 2014-09-22  
updated: 2023-04-28  
canonical: https://www.mindstick.com/forum/2265/is-it-possible-to-calculate-the-sum-of-each-group-in-a-table-without-using-group-by-clause-in-sql-server  
category: "database"  
tags: ["database"]  
reading_time: 2 minutes  

---

# Is it possible to calculate the sum of each group in a table without using group by clause in SQL Server?

I [am trying](https://answers.mindstick.com/qa/36834/which-two-programming-languages-should-i-master-in-if-i-am-trying-to-get-into-google-or-facebook) to find out if there is any way to [aggregate](https://www.mindstick.com/blog/52/aggregate-functions-in-database) a [sales](https://www.mindstick.com/articles/13125/tips-to-increase-sales-of-your-woocommerce-store) for each Book. I realize I can achieve it either by using [group](https://yourviews.mindstick.com/view/81323/adani-green-energy-group-bags-world-s-biggest-solar-bid)-by [clause](https://www.mindstick.com/forum/33937/difference-between-throw-exception-and-throw-clause) or by [writing](https://www.mindstick.com/articles/12997/5-essential-tips-on-resume-writing-for-business-analysts) a [procedure](https://www.mindstick.com/forum/32/stored-procedure-return-datatype). Example:

## [Table](https://www.mindstick.com/articles/43918/how-to-design-table-using-bootstrap): Details

**Sales Book**

10 C [Language](https://www.mindstick.com/startup/28/preply-the-fast-growing-platform-transforming-language-learning)

20 C Language

4 C# 4.0

12 C# 4.0

2 C# 4.0

25 Java

Is there a way possible to perform the following query without using group by query?

```
select     Book,     sum(Sales) from     Details group by     Book
```

I realize it is possible using Procedure, could it be done in any other way?\

## Replies

### Reply by Aryan Kumar

No, it is not possible to calculate the sum of each group in a table without using the GROUP BY clause in SQL Server.

The GROUP BY clause is used to group rows together based on one or more columns, and then aggregate functions such as SUM can be applied to each group to calculate the sum of a specific column or columns for each group.

Without using the GROUP BY clause, the query would simply calculate the sum of the entire column, without any grouping or aggregation by specific columns. This would not provide the desired result of calculating the sum of each group in the table.

Therefore, it is necessary to use the GROUP BY clause in SQL Server to calculate the sum of each group in a table.

\

### Reply by Anchal Kesharwani

hi john,\

I hope that its helpful for you:

```
SELECT Distinct(Book),     (SELECT SUM(Sales) FROM Details x where x.Book = a.Book) Salesfrom Details a;
```

\

\


---

Original Source: https://www.mindstick.com/forum/2265/is-it-possible-to-calculate-the-sum-of-each-group-in-a-table-without-using-group-by-clause-in-sql-server

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
