Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

SQL Query Row wise sum (dynamic columns)

PS SPDec 15 2015 — edited Dec 18 2015

Need a help in writing oracle query

I have a table Test with following information

 

DIM1

DIM2

DIM3

DIM4

DIM5

DIM6

SM1

SM2

SM3

SM4

SM5

SM6

A

B

C

D

E

F

1

2

3

4

5

6

A

B

C

D

E

F

2

2

2

2

2

2

I would need data with sum row wise, I wrote this query it works.

select DIM1, DIM2,DIM3,DIM4,DIM5,DIM6,(SM1+SM2+SM3+SM4+SM5+SM6) from  Test

But my requirement in table columns might increase, hence I would need this query to be dynamic, it should work though any additions or deletions in columns with out changing query.We are using Oracle 11g.

Thanks in advance.

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 15 2016
Added on Dec 15 2015
20 comments
2,786 views