View previous topic :: View next topic
|
Author |
Message |
pradeep_123
New User
Joined: 21 Nov 2007 Posts: 9 Location: bhubaneswar
|
|
|
|
hi all,
i am having a table which contain 3 records.let table name be EMP and columns are C1,C2 C3 which contains integer values.
i want to get sum of all rows of all columns. Suppose assume that C1 ,C2,C3 contains values (1,2,3) ,(4,5,6) and (7,8,9)
(1+2+3+4+5+6+7+8+9)=45.
i want total as single value as 45.
Can any one please help me to get the query.
This is my first post in this form.if any mistakes plz excuse. |
|
Back to top |
|
|
Prajesh_v_p
Active User
Joined: 24 May 2006 Posts: 133 Location: India
|
|
|
|
Why cant you try the below query:
Select sum(c1) + sum (c2) + sum (c3)
from table
Thanks,
Prajesh V P |
|
Back to top |
|
|
pradeep_123
New User
Joined: 21 Nov 2007 Posts: 9 Location: bhubaneswar
|
|
|
|
Thank you for ur answer.
but ,I think it will be very difficult if the table contains more than 10 columns . |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
pradeep_123 wrote: |
... but ,I think it will be very difficult if the table contains more than 10 columns . |
and why do you think that? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
pradeep wrote: |
i want to get sum of all rows of all columns. |
Quote: |
Why cant you try the below query:
Select sum(c1) + sum (c2) + sum (c3) |
pradeep wrote: |
but ,I think it will be very difficult if the table contains more than 10 columns . |
Your concern is not clear to us. To sum the columns, you would need to name them . . . Where does the difficulty come in? |
|
Back to top |
|
|
|