Excluding records

  • I only want the records where the condition is not true. This select gets those records where the tons variance is small. But, I want to exclude thos records.

    SELECT Distinct BNumber,

    er.Art_Tons,

    er.Voy_Tons

    FROM (ExceptionRpt er

    LEFT OUTER JOIN MT_VG ON

    er.voyage_id = MT_VG.voyage_id AND

    er.BNumber = MT_VG.vessel_id)

    LEFT OUTER JOIN MT_BF MT_BF ON

    er.BNumber = MT_BF.barge_id

    WHERE ((er.Art_Tons - er.Voy_Tons) > -0.5 AND (er.Art_Tons - er.Voy_Tons) < 0.5 )

  • WHERE NOT ((er.Art_Tons - er.Voy_Tons) > -0.5 AND (er.Art_Tons - er.Voy_Tons) < 0.5 )

    WHERE (er.Art_Tons - er.Voy_Tons) <= -0.5 OR (er.Art_Tons - er.Voy_Tons) >= 0.5


    N 56°04'39.16"
    E 12°55'05.25"

  • Duh...sorry, didn't realize it was that simple. Thanks.

  • Would I be correct in adding that NOT will void the use of an index, if one exists on the field - not SARGable.

    And therefore opt instead for the inversion of the lt/gt as a general principle?

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

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