Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Adding column data in db2 sql query

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: Adding column data in db2 sql query
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    Post subject:
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    Post subject:
Reply with quote

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

Global Moderator


Joined: 14 Mar 2007
Posts: 10232
Location: italy

PostPosted: Wed Jun 16, 2010 1:35 am    Post subject: Reply to: Adding column data in db2 sql query
Reply with quote

anything wrong in looking at the manuals icon_question.gif


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

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

http://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: 72
Location: Chennai

PostPosted: Fri Jun 18, 2010 10:17 pm    Post subject: Reply to: Adding column data in db2 sql query
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    Post subject: Re: Reply to: Adding column data in db2 sql query
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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Data replication from multiple Db2 ta... kishpra DB2 5 Mon Mar 27, 2017 9:58 pm
No new posts Export flat file data into excel sheet murali.andaluri DFSORT/ICETOOL 2 Mon Mar 20, 2017 5:39 pm
No new posts Append data from two files into a sin... Praveen04 DFSORT/ICETOOL 5 Thu Mar 16, 2017 7:29 pm
No new posts JCL to Set Return code based on DB2 S... vinu78 DB2 17 Mon Mar 13, 2017 9:47 pm
No new posts SPUFI -- Joining 3 tables – data in... Sysaron DB2 2 Wed Mar 08, 2017 4:18 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us