﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2005 / SQL Server 2005 General Discussion  / Help reqd for eliminating a similar IDs- Query / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Thu, 23 May 2013 07:31:55 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Help reqd for eliminating a similar IDs- Query</title><link>http://www.sqlservercentral.com/Forums/Topic489765-149-1.aspx</link><description>Thanks friend,The mentioned query does not meet the requirement. If we run the query BATCH ID 121 and the ID 1 &amp; 2 are shown which is not required.regardsSaravanakumar.R</description><pubDate>Fri, 25 Apr 2008 03:31:54 GMT</pubDate><dc:creator>Saravanakumar.Rathinam</dc:creator></item><item><title>RE: Help reqd for eliminating a similar IDs- Query</title><link>http://www.sqlservercentral.com/Forums/Topic489765-149-1.aspx</link><description>select * from table1 where id not in (select id from table1 where status='rework')</description><pubDate>Fri, 25 Apr 2008 03:11:00 GMT</pubDate><dc:creator>sameyullah</dc:creator></item><item><title>RE: Help reqd for eliminating a similar IDs- Query</title><link>http://www.sqlservercentral.com/Forums/Topic489765-149-1.aspx</link><description>Here are two more options:[font="Courier New"]SELECT DISTINCT	T1.*FROM	myTable T1	LEFT JOIN myTable T2 ON T1.BatchID = T2.BatchID						AND T2.Status = 'Rework'WHERE	T2.BatchID IS NULLSELECT	T1.*FROM	myTable T1WHERE	NOT EXISTS (SELECT * FROM myTable T2 WHERE T2.Status = 'Rework' AND T2.BatchID = T1.BatchID)[/font]The first should outperform the second if your indexing is correct.</description><pubDate>Thu, 24 Apr 2008 08:37:08 GMT</pubDate><dc:creator>Michael Earl-395764</dc:creator></item><item><title>RE: Help reqd for eliminating a similar IDs- Query</title><link>http://www.sqlservercentral.com/Forums/Topic489765-149-1.aspx</link><description>Thanks for your reply,I did the same, but the performance of the query is not really good, it taking such a long time to get the result, and every row the query touches twice.is it possible to get same thing with better result using CTE / derived queries ?thanks &amp; regardsSaravanakumar.R</description><pubDate>Thu, 24 Apr 2008 04:58:12 GMT</pubDate><dc:creator>Saravanakumar.Rathinam</dc:creator></item><item><title>RE: Help reqd for eliminating a similar IDs- Query</title><link>http://www.sqlservercentral.com/Forums/Topic489765-149-1.aspx</link><description>select * from myTable where BatchID not in (select BatchID from myTable where Status = 'Rework')</description><pubDate>Thu, 24 Apr 2008 04:26:41 GMT</pubDate><dc:creator>RyanRandall</dc:creator></item><item><title>Help reqd for eliminating a similar IDs- Query</title><link>http://www.sqlservercentral.com/Forums/Topic489765-149-1.aspx</link><description>Hi all,I need a basic query based on the below conditions Sample recordsID        BatchID        Status1          121             COMPLETE2          121             PENDING3          121             REWORK4          122             ACK5          123             TBKReqd Output ID        BatchID        Status4          122             ACK5          123             TBKIf the Status = 'REWORK", I don't want the Particular batchID to the output. Kindly help me to write the query.thanks &amp; regardsSaravanakumar.R</description><pubDate>Thu, 24 Apr 2008 04:10:09 GMT</pubDate><dc:creator>Saravanakumar.Rathinam</dc:creator></item></channel></rss>