IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

SUM of row values using SQL


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Himanshu Khatri

New User


Joined: 11 Jun 2007
Posts: 15
Location: Pune

PostPosted: Thu Oct 11, 2007 4:25 pm
Reply with quote

Hi,

I have a table having columns: item number & 52 columns where each column represents 1 column.(1 year =52 weeks). Each 52 columns has number of sales of item.
I have to find through query cumulative sum of sales of particular item.
e.g. When user provides item number 7 & week number 10, SQL should return sum of(column1 + column2 +---+ column7) for item number 7.

TIA
Back to top
View user's profile Send private message
saptagiri kintali

New User


Joined: 21 Sep 2007
Posts: 20
Location: chennai

PostPosted: Thu Oct 11, 2007 6:30 pm
Reply with quote

hi,
try this..
SELECT (COL1 + COL2....) AS NEWCOL FROM <TABE NAME> WHERE <COND..>
Back to top
View user's profile Send private message
TG Murphy

Active User


Joined: 23 Mar 2007
Posts: 148
Location: Ottawa Canada

PostPosted: Thu Oct 11, 2007 7:53 pm
Reply with quote

Whoever defined your table that way should really be responsible for answering your question.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Null values are considered in Total c... DFSORT/ICETOOL 6
No new posts Converting ASCII values to COMP-3 (ZD... JCL & VSAM 2
No new posts Generate output lines (SYSIN card for... DFSORT/ICETOOL 4
Search our Forums:

Back to Top