Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Modulo Question for SQL Server

Status
Not open for further replies.

KIDDIE

Programmer
Feb 11, 2002
5
US
SELECT
ACCOUNT_NUMBER,
EM_NO + IN_BANK + NT_BANK AS SPA,
CURRENT_BALANCE,
CYCLE_CODE_99

FROM
dbo.MASTER_CUR
WHERE
((EM_NO + IN_BANK + NT_BANK) IN
('502650000000', '851190000000')) AND
(CURRENT_BALANCE between 1600 AND 5000)and
CYCLE_CODE_99 in(2,4,6,8,12,14,16,18,20)


All I need is the the Even numbered cycle codes?
How can write this query without hard coding Cycle code? Thank you
 
Hiya,

You could try

SELECT
ACCOUNT_NUMBER,
EM_NO + IN_BANK + NT_BANK AS SPA,
CURRENT_BALANCE,
CYCLE_CODE_99

FROM
dbo.MASTER_CUR
WHERE
((EM_NO + IN_BANK + NT_BANK) IN
('502650000000', '851190000000')) AND
(CURRENT_BALANCE between 1600 AND 5000)and
CYCLE_CODE_99 % 2 = 0

The %2 = 0 will basicaly perform a divide by 2 and then check to see if the number is an integer. If so, it will be true, if not, it will be false.

HTH

Tim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top