If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Modulus Operator Help

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-16-09, 00:42
dinjo_jo dinjo_jo is offline
Registered User
 
Join Date: May 2008
Posts: 34
Modulus Operator Help

I'm trying to do a modulus on DB2 but it fails % is not a valid

and (COLA/COLB)%10 != 0
Reply With Quote
  #2 (permalink)  
Old 12-16-09, 01:07
tonkuma tonkuma is offline
Registered User
 
Join Date: Feb 2008
Location: Japan
Posts: 2,193
Mod(cola/colb, 10)
Reply With Quote
  #3 (permalink)  
Old 12-16-09, 01:34
dinjo_jo dinjo_jo is offline
Registered User
 
Join Date: May 2008
Posts: 34
It says no aothorized routine named Mod of type function having compatible arguments were found.
Reply With Quote
  #4 (permalink)  
Old 12-16-09, 02:20
tonkuma tonkuma is offline
Registered User
 
Join Date: Feb 2008
Location: Japan
Posts: 2,193
What are the data types of cola and colb?

What platform and DB2 version/release are you using?

Here is an example on DB2 9.7 for Windows.
Code:
------------------------------ Commands Entered ------------------------------
SELECT cola , colb
     , cola / colb        division
     , MOD(cola/colb, 10) modulus
  FROM(VALUES (191, 13) ) r(cola, colb);
------------------------------------------------------------------------------

COLA        COLB        DIVISION    MODULUS    
----------- ----------- ----------- -----------
        191          13          14           4

  1 record(s) selected.
Reply With Quote
  #5 (permalink)  
Old 12-16-09, 02:51
dinjo_jo dinjo_jo is offline
Registered User
 
Join Date: May 2008
Posts: 34
Both columns are decimal
Reply With Quote
  #6 (permalink)  
Old 12-16-09, 02:55
tonkuma tonkuma is offline
Registered User
 
Join Date: Feb 2008
Location: Japan
Posts: 2,193
DB2 9.7.1 Express-C on Windows.
Code:
------------------------------ Commands Entered ------------------------------
SELECT cola , colb
     , cola / colb        division
     , MOD(cola/colb, 10) modulus
  FROM(VALUES (191.9, 13.1) ) r(cola, colb);
------------------------------------------------------------------------------

COLA   COLB  DIVISION                          MODULUS    
------ ----- --------------------------------- -----------
 191.9  13.1    14.648854961832061068702290076           4

  1 record(s) selected.

Last edited by tonkuma; 12-16-09 at 03:04.
Reply With Quote
  #7 (permalink)  
Old 12-16-09, 03:00
tonkuma tonkuma is offline
Registered User
 
Join Date: Feb 2008
Location: Japan
Posts: 2,193
Quote:
It says no aothorized routine named Mod of type function having compatible arguments were found.
Please give me your query, results and error messages(full text you received).
Reply With Quote
  #8 (permalink)  
Old 12-16-09, 04:05
dinjo_jo dinjo_jo is offline
Registered User
 
Join Date: May 2008
Posts: 34
SELECT COLA,
COLB,
MOD(COLA/ COLB, 10)
FROM TABLE
WITH ur
Reply With Quote
  #9 (permalink)  
Old 12-16-09, 06:28
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
And the exact error message (incl. message number)?
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On