I'm working with a relational database that uses SQL99.
I have a series of 10 columns, each of the 10 columns contain a number value.
I need to sum each column individually and then take those sums and add them all together to get an overall sum. Then I must divide the overall sum by 15.
I've tried every format I can think of and have yet to return any results. I have no idea what the syntax should look like.
SELECT SUM(col1), SUM(col2)..., SUM(col1 + col2 + col3 + col4...)/15
FROM TABLENAME
GROUP BY 1=1
select
sum(col1) as sum1,
sum(col2) as sum2,
sum(col3) as sum3,
sum(col4) as sum4,
sum(col5) as sum5,
sum(col6) as sum6,
sum(col7) as sum7,
sum(col8) as sum8,
sum(col9) as sum9,
sum(col10) as as sum10,
sum( col1 + col2 + col3 + col4 + col5 + col6 + col7 + col8 + col9 + col10) as overallsum,
sum( col1 + col2 + col3 + col4 + col5 + col6 + col7 + col8 + col9 + col10) / 15 as dividedsum
from
tablename
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