Is it what you're after?
SELECT 72/5, CASE WHEN 72%5=0 THEN 'No fraction' ELSE 'Fraction' end
Using modulus operation?
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
How do you check if this is a fraction?
select 72/5
Is it what you're after?
SELECT 72/5, CASE WHEN 72%5=0 THEN 'No fraction' ELSE 'Fraction' end
Using modulus operation?
Do you mean this:
SELECT CASE WHEN 72 % 5 = 0 THEN 0 ELSE 1 END [Fraction];
Hi @
In SQLSever, if 2 ints are /, it will return int.If you want the result to become float,you may multiply one of the INTs by 1.0
Check this:
SELECT 72 / 5,
1.0 * 72 / 5
Best regards,
LiHong
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our Documentation to enable e-mail notifications if you want to receive the related email notification for this thread.