Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
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 DISTINCTI 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 wantMadhivananFailing to plan is Planning to fail
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 tableAgroup by field1, field2, field3