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

Adding column data in db2 sql query


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

New User


Joined: 13 Apr 2010
Posts: 2
Location: SanDiego,USA

PostPosted: Wed Jun 16, 2010 1:27 am
Reply with quote

Hi! There are two decimal data columns in a DB2 table.
Col 1 is Decimal(5,0) and col2 is decimal(5,0).
I want to add both these column datas in my sql query.
Can you please help.

ex.

SELECT COL1,COL2, COL1+COL2 FROM TABLE
Back to top
View user's profile Send private message
Anamikaa

New User


Joined: 13 Apr 2010
Posts: 2
Location: SanDiego,USA

PostPosted: Wed Jun 16, 2010 1:29 am
Reply with quote

I tried to use digits( function. I didn't get any SQL error.
But the result is not getting displayed
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Wed Jun 16, 2010 1:34 am
Reply with quote

col1 + col2 works fine for me.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Wed Jun 16, 2010 1:35 am
Reply with quote

anything wrong in looking at the manuals icon_question.gif


publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/Shelves/DSNSHKA3
for the full shebang

publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/DSNSQK15/CCONTENTS?SHELF=DSNSHKA3&DN=SC18-9854-05&DT=20081120084907
for the sql reference

publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/DSNSQK15/2.22?SHELF=DSNSHKA3&DT=20081120084907
for expressions

faster than asking on a forum..
remember... searching for it Yourself will help You to remember better about it
Back to top
View user's profile Send private message
cmsmoon

New User


Joined: 17 Jun 2010
Posts: 75
Location: Chennai

PostPosted: Fri Jun 18, 2010 10:17 pm
Reply with quote

i think it is working for numerica data...


select col,col2,col1 + col2 from table
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Fri Jun 18, 2010 10:23 pm
Reply with quote

cmsmoon wrote:
i think it is working for numerica data...


select col,col2,col1 + col2 from table


Addition is not defined for nonnumeric data!!!
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 How to save SYSLOG as text data via P... All Other Mainframe Topics 4
No new posts Replacing 'YYMMDD' with date, varying... SYNCSORT 3
No new posts Store the data for fixed length COBOL Programming 1
No new posts Data set Rec-Cnt and Byte-Cnt Testing & Performance 2
No new posts How to load to DB2 with column level ... DB2 6
Search our Forums:

Back to Top