I have a Table which has following columns.

I want to get results with the same number of columns but with sum of running Balance with Account code not repeating more than once i tried this query
select AccountCode , 'All Companies' as divisionName , AcName , LF_AccountType , Sum(ISNULL(runningBalance,0)) as runningBalance from Table
group by AccountCode , divisionName , AcName , LF_AccountType
it's unclear what your problem is. However, All columns in the group by statement must be in or derived from the tables queried. So you can't use divisionname in your group by. And you don't need it. So, the immediate syntactic fix would be:
select AccountCode , 'All Companies' as divisionName , AcName ,
LF_AccountType , Sum(ISNULL(runningBalance,0)) as runningBalance
from Table
group by AccountCode, AcName , LF_AccountType
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With