Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2005
    Posts
    266

    Unanswered: keeping last 10 entries by ID

    Hello

    my table :
    Report :
    R_id (PK)
    RName
    RDate


    i am having a few 10.0000 lines and i want to keep the last 10 (or less if not in the table) rows maximum for each name

    i can have 100 report by name (100 rows with the same name and of course R_id and RDate are different)

    how can i do it ?

    thanks a lot for helping

  2. #2
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    Code:
    delete
    from	Report
    where	R_id not in
    	(select	top 10
    		R_Id
    	from	Report Report2
    	where	Report2.RName = Report.RName
    	order by RDate desc)
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •