Forum Moderators: open

Message Too Old, No Replies

Find rows of securities not divisable by 5

         

shaan1980

5:48 pm on Jun 20, 2006 (gmt 0)

10+ Year Member




Hello

How would I be able to query a database and find all issues where their value was not fully devisable by 5 .
eg : -

NAME AGE
SAM 25
HAM 33

I want my query to return only HAM's name

If you can keep your queries sybase centric that would really help

aspdaddy

6:00 pm on Jun 20, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You need the modulus operator, in MSSQL I think its select name from table where age mod 5 <> 0

shaan1980

8:52 pm on Jun 20, 2006 (gmt 0)

10+ Year Member



would you happen to have a sybase syntax

coopster

9:49 pm on Jun 20, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



The mathematical function named
MOD
became a standard in SQL3. It stands for "modulus" but the result of the function is not really a modulus, it is a remainder.

I would be very surprised if either the function itself doesn't work or it's mathematical character, the percent sign (%):

SELECT NAME FROM table WHERE age % 5;

Sybase should be advanced enough to have this feature. You may have to check the manual for specifics.

syber

12:21 pm on Jun 21, 2006 (gmt 0)

10+ Year Member



Sybase should be the same, as MSSQL is a deriviative of Sybase.

SELECT name FROM table WHERE age MOD 5 <> 0