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)
 comparing rows

Author  Topic 

achowe
Starting Member

6 Posts

Posted - 2003-07-17 : 06:02:06
Is there any way of comparing specific rows in a table? i.e. I want to delete one of two rows in a table (that also has more rows in it other than the 2 i want to compare). Basicaly, each of the rows have a date field and a unique idtntifier, I want to compare two rows against each other using the unique indetifier and delete the one with the earliest date.

Anyone know how this can be done?

appreciated.........

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2003-07-17 : 07:39:56
OK ... I'll ask:

if each row has a unique identifier, how do you determine which two rows to compare to take the one with the earliest date?

how about posting a create table statment, an INSERT statement putting in some sample data, and what you hope to return as results. Makes it much easier for us to help ...

example:

create table foo (f1 int, f2 int)

insert into foo
select 1,2
union
select 3,4
union
select 5,6

select * from foo where f2 > 2

- Jeff
Go to Top of Page

drymchaser
Aged Yak Warrior

552 Posts

Posted - 2003-07-17 : 15:35:01
1. Could I ask why this is an issue for this table?
...ie Somebody loaded duplicate info or...

2. There has to be some other commonality between rows that can be used to group on so the the earlier row can be "identified" other than date because date in SQL db is difficult/unreliable for this purpose.

thanks,
drymchaser



Go to Top of Page
   

- Advertisement -