SQL Server Performance

Records - help is needed!

Discussion in 'T-SQL Performance Tuning for Developers' started by alex, Jan 5, 2005.

  1. alex New Member

    Hello, guys.

    My records (but not all) are the same with the exception of int1 (int1 are 1,2,3,4).

    To get the latest records, I use the statement like this:

    select * from table1 where exists
    (select * from table1 as t
    where t.column1 = table1.column1 and
    t.int1 > table1.int1)

    But it is not what I need, because it doesn't also select the records without duplication - where int1 has only one value.

    Thanks for your help.
  2. Adriaan New Member

    Just add
    or not exists (select * from table1 as t
    where t.column1 = table1.column1 and
    t.int1 <> table1.int1)

Share This Page