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

divide operator in select statement


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

New User


Joined: 20 May 2008
Posts: 8
Location: Hyderabad

PostPosted: Mon Dec 08, 2008 9:25 pm
Reply with quote

i am selecting 10 fields from a table .
can i use divide operator in select statemnt for caluculating the resultant filed which is not a column of the table, but the fileds paticipating in the divide operator are present in the table.

let's say
PAID-AMOUNT-PER-UNIT =C-LI-CLC-ALLW-AMT/C-LI-ALLOW-UNT-NUM
Here C-LI-CLC-ALLW-AMT, C-LI-ALLOW-UNT-NUM are fileds of a table but
PAID-AMOUNT-PER-UNIT is not a filed of this table or any other table. can i do the above operation in the select statement
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Mon Dec 08, 2008 10:45 pm
Reply with quote

pardhasaradhireddy,

Yes, we can do arithmetic operations using different columns of a table and name the resultant column provided the operand column definitions are of numeric type.
Back to top
View user's profile Send private message
pardhasaradhireddy

New User


Joined: 20 May 2008
Posts: 8
Location: Hyderabad

PostPosted: Mon Dec 08, 2008 10:49 pm
Reply with quote

how can u reply me with sample code
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Mon Dec 08, 2008 11:00 pm
Reply with quote

Hello,

Suggest you build a prototype query with the operations you want to accomplish and we can help you get it running if there are problems.

When you post your code, please use the "Code" tag at the top of the reply panel for readability (green on black) as well as preserve alignment. Use Preview to see how your post will appear to the forum and when you are satisfied with the appearance, Submit.
Back to top
View user's profile Send private message
umasankarmf

New User


Joined: 08 Sep 2008
Posts: 43
Location: india

PostPosted: Tue Dec 09, 2008 12:14 pm
Reply with quote

Hi pardhasaradhireddy,

You can use the following query.


select C-LI-CLC-ALLW-AMT/C-LI-ALLOW-UNT-NUM as PAID-AMOUNT-PER-UNIT from TAB_NAME

The name which is using after AS is only for display purpose.

If any corrections ............... well come.....

Regards
Umasankar M
Back to top
View user's profile Send private message
pardhasaradhireddy

New User


Joined: 20 May 2008
Posts: 8
Location: Hyderabad

PostPosted: Tue Dec 09, 2008 1:57 pm
Reply with quote

thank you
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 Dynamically pass table name to a sele... DB2 2
No new posts SELECT from data change table DB2 5
No new posts Select two different counts from SQL... DB2 6
No new posts JOIN STATEMENT PERFORMANCE. DFSORT/ICETOOL 12
No new posts Select a DB2 value in a specific deci... DB2 4
Search our Forums:

Back to Top