September 17, 2008 at 4:56 pm
I have a table whose data is already grouped by the first column:
1 2 7
1 2 5
1 7 3
1 4 9
2 3 4
This first group (column1 = 1) has 4 rows; the second "group" contians a single row
In each group I want to delete all records after the first record in that group. In the above case here's what the end result looks like.
1 2 7 (the first row of the group)
2 3 4 (the first and only row in the singleton gorup).
How to do this in sql 2000 is the question.
TIA,
Barkingdog
September 17, 2008 at 6:35 pm
As so many will, undoubtedly, tell you, how do you know what the "first" record really is? There's no guarantee that the order you enter the data will stay that way. There has to be a column or set of columns to sort on to identify what "first" means.
--Jeff Moden
Change is inevitable... Change for the better is not.
September 17, 2008 at 7:06 pm
The first column, not shown, could well be an identity column. So the first row could have ID = 1, the next row 2, etc....
Bill
September 17, 2008 at 7:10 pm
In that case, please take a peek at the link in my signature. It'll help use help you faster and better. 😉
--Jeff Moden
Change is inevitable... Change for the better is not.
September 18, 2008 at 12:07 am
Good URL. I will recast my original "question" using some of the ideas in your article.
Barkingdog
Viewing 5 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply