14,981,116 members
See more:
I am trying to get the total count over selected columns in my table.

I have 45 columns in my table. I need 43 of them summed and totaled for a counter.

I can not seem to get this sql statement to work:
SQL
`SELECT SUM([index],[01],[02],...,[at]) FROM [count];`

The "..." are the rest of the 43 columns.

Can you help?
Posted

What is the issue? Any errors?

## Solution 3

SUM is an aggregate, not a genaric function. I don't know get your final goal, but these are your options:
Simply use addition, to get the sum of specific culumn values. You will get as many rows as your selection gives:
SQL
`SELECT [index]+[01]+[02]+...+[at] as [SUM] FROM [count];`

You can summarize each column on it's own. You will get one row, with as many values, as many columns you add:
SQL
`SELECT SUM([index]), SUM([01]), SUM([02]),...,SUM([at]) FROM [count];`

And of course, you can combine these, to get the sum of all:
SQL
`SELECT SUM([index]+[01]+[02]+...+[at]) as [SUM] FROM [count];`

## Solution 1

Try `SELECT SUM([index]), sum([01]),sum([02]),sum([03]),sum([04])... FROM [count];`

## Solution 2

try like
SQL
```SELECT
(col1+ col2 + .... +coln) as ROWTOTAL
FROM
TABLENAME```