Trying to understand percent sign next to field name

  • I have a simple query where I needed to see if a qty had decimal places. I was instructed to use field_name%1 as shown below. It works. I'm just trying to understand the process so I can learn more. What is the %1 doing/calculating?

    SELECT m.item_id
    , l.qty_on_hand
    FROM inv_loc l
    INNER JOIN inv_mast m
    ON m.inv_mast_uid = l.inv_mast_uid
    WHERE l.qty_on_hand%1 <> 0

     

  • % returns a remainder from division.

    So, 1.1 % 1 yields 0.1.

    2.54 % 1 = 0.54

    3.0 % 1 = 0.

    SQL DBA,SQL Server MVP(07, 08, 09) A socialist is someone who will give you the shirt off *someone else's* back.

  • Simple enough. It just takes the field name and divides by 1, removes any whole number, and returns the balance. In this case, decimals. Thank you.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply