Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8378655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:58:37+00:00 2026-06-09T15:58:37+00:00

I came across the following SQL statement: SELECT A.NAME FROM THE_TABLE A WHERE A.NAME

  • 0

I came across the following SQL statement:


    SELECT A.NAME
    FROM   THE_TABLE A
    WHERE  A.NAME LIKE '%JOHN%DOE%'
    AND    ((A.NUM_FIELD/1) - (A.NUM_FIELD/2)*2 <> 0)


That last condition, "((A.NUM_FIELD/1) - (A.NUM_FIELD/2)*2 <> 0)" is what baffles me. Depening on the implementation of order of operations, it should always result to 0 or A.NUM_FIELD / 2.

How does SQL still return records from this view? If it always results to half the original value, why have it? (This is a delivered SQL package)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T15:58:39+00:00Added an answer on June 9, 2026 at 3:58 pm

    What SQL implementation is this?

    As noted,

    (x/1) - (x/2)*2
    

    is equivalent to

    X - (2*(x/2))
    

    which, if integer division is being performed yields 0 or 1 depending on whether the value is even or odd:

    x x/2 2*(x/2) x-(2*(x/2))
    - --- ------- -----------
    0   0       0           0
    1   0       0           1
    2   1       2           0
    3   1       2           1
    4   2       4           0
    ...
    

    if so, it seems like an odd way way of checking for odd/even values, especially since most SQL implementations that I’m aware of support a modulo operator or function, either x % y or mod(x,y).

    The seemingly extraneous division by 1 makes me think the column in question might be floating point. Perhaps the person who coded the query is trying to check for jitter or fuzzyness in the low order bits of the floating point column?

    if you modified the query to return all the intermediate values of the computation:

    SELECT A.NAME                    as Name      ,
           A.NUM_FIELD               as X         ,
           A.NUM_FIELD / 1           as X_over_1  ,
           A.NUM_FIELD / 2           as X_over_2  ,
           ( X.NUM_FIELD / 2 )
           * 2                       as 2x_over_2 ,
             ( A.NUM_FIELD / 1 )
           - ( A.NUM_FIELD / 2 ) * 2 as Delta ,
           case when ( ( A.NUM_FIELD / 1 ) - ( A.NUM_FIELD / 2 ) * 2 ) <> 0
           then 'return'
           else 'discard'
           end as Row_Status
    FROM   THE_TABLE A
    WHERE  A.NAME LIKE '%JOHN%DOE%'
    

    and then executed it, what results do you get?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I came across the following SQL statement and I was wondering if it was
I came across following code and don't know what does having from twice mean
I came across the following code that compiles fine (using Visual Studio 2005): SomeObject
i came across the following ex, of displaying only the department name of employess
I'm trying to optimize SQL queries in Akonadi and came across the following problem
I came across the following exploit due to a warning from my AV software.
I came across the following SQL in a book: CREATE TABLE 'categories'( id SMALLINT
I came across the following code and am wondering what the #statement means and
I came across a rather strange problem with linq-to-sql. In the following example, var
I came across the following code in a book recently. It says that we

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.