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: 10274
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: 75
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 copying data without knowing location arunsoods DFSORT/ICETOOL 6 Thu Jul 20, 2017 1:03 pm
This topic is locked: you cannot edit posts or make replies. Fetching data from BAI File arunsoods JCL & VSAM 1 Wed Jul 19, 2017 4:28 pm
No new posts Loading data to table gives wrong for... Raghu navaikulam DB2 19 Thu Jul 13, 2017 2:11 pm
No new posts SQL - select data available in index Nileshkul DB2 3 Mon Jun 26, 2017 1:30 am
No new posts NDM syntax checking without actually ... GAPX1 All Other Mainframe Topics 0 Wed Jun 07, 2017 2:36 am


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