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

Author  Topic 

sergio
Starting Member

1 Post

Posted - 2005-10-19 : 06:18:09
Hi there i am fairly new to SQL and am having issues with duplicate rows.

My SELECT query is pulling data does have duplicate records, in the SELECT there is a date field however that is not a duplicate value that if I can right a script to only pull the latest record only i am sure it would work the way i want. I have tried DISTINCT

I have no idea how to approach this!

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-10-19 : 06:19:01
Post some sample data and the result you want

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Antonio
Posting Yak Master

168 Posts

Posted - 2005-10-19 : 06:53:13
Hi Sergio,

Without knowing your table structure, it's not possible to give you a precise answer, but this might be of help to you.

If you have a table A consisting of 4 columns of which the 4th is a date field. If you want to select the earliest date and the associated record then you would do something like :


select field1 field2, field3, min(field4)
from tableA
group by field1, field2, field3


Hope this helps.
Go to Top of Page
   

- Advertisement -