check if fraction

Thirston Third 21 Reputation points

How do you check if this is a fraction?
select 72/5

A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,575 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Naomi 7,361 Reputation points

    Is it what you're after?

    SELECT 72/5, CASE WHEN 72%5=0 THEN 'No fraction' ELSE 'Fraction' end

    Using modulus operation?

    0 comments No comments

  2. Guoxiong 8,126 Reputation points

    Do you mean this:

    SELECT CASE WHEN 72 % 5 = 0 THEN 0 ELSE 1 END [Fraction];  


    0 comments No comments

  3. LiHong-MSFT 10,046 Reputation points

    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,

    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.

    0 comments No comments