Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 select SQL statement

Author  Topic 

eip
Starting Member

2 Posts

Posted - 2005-03-23 : 10:16:55
Hi I have a table with 3 columns (ID, old, new). I want to retrieve record for each ID where data in "new" column not in "old" column.
In this example, I want to get '1, A1, B1' and '2, A, B1'. Thank you!!!

ID old new
1 '' A
1 A A1
1 A1 B1
2 '' A
2 A B1

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2005-03-23 : 10:18:51
why not 1, A, A1 ? Based on the critera you have described, that should be returned to. You need to be specific in what you are looking to accomplish; the computer won't "know what you mean".

- Jeff
Go to Top of Page

eip
Starting Member

2 Posts

Posted - 2005-03-23 : 10:27:24
actually old and new are old version number and new version number respectively. I want to get the record for each ID with most updated new version number. This is why 1, A1, B1 and 2, A, B1.

Thanks!
Go to Top of Page

irislaw
Starting Member

7 Posts

Posted - 2005-03-23 : 13:13:14
Can you try this one and see if it works?
I tried it, it returns:

ID Old New
---- ---- ----
1 A1 B1
2 A B1

select * from #T1 where new NOT in (select Old from #T1)
Go to Top of Page
   

- Advertisement -