Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3620032
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T22:57:13+00:00 2026-05-18T22:57:13+00:00

We have a history table which is defined as follows: –ID (pk) ———–Object ID————–Work

  • 0

We have a history table which is defined as follows:

--ID (pk) -----------Object ID--------------Work ID--------date------
  1                  1111                   AAAA           1/1/2010
  2                  1111                   AAAA           1/2/2010
  3                  2222                   BBBB           1/1/2010
  4                  3333                   CCCC           1/1/2010
  5                  1111                   DDDD           1/3/2010

We need the latest (date-based NOT id-based) row PER Work ID. Note that an object ID can have multiple work id’s and we need the latest for EACH work ID.

What we need as our result set:

ID (pk) -----------Object ID--------------Work ID--------date------
2                  1111                   AAAA           1/2/2010
3                  2222                   BBBB           1/1/2010
4                  3333                   CCCC           1/1/2010
5                  1111                   DDDD           1/3/2010

Thoughts/Ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T22:57:13+00:00Added an answer on May 18, 2026 at 10:57 pm
    SELECT  *
    FROM    (
            SELECT  h.*, 
                    ROW_NUMBER() OVER (PARTITION BY workID ORDER BY date DESC) AS rn
            FROM    history
            )
    WHERE   rn = 1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If you have a table which holds history (updates, deletes) from another table, how
I have a table which includes all the users video downloading history: src_ip vlan_id
I have a database table called AllCustomersHistoryOfRecords which is table with history of all
I have a History Table in SQL Server that basically tracks an item through
I have 2 tables product and history product table: id name type price location
So I have a User table and a History table with User hasMany Histories,
I have a table named Books which contains some columns. ColumnNames: BookId, BookName, BookDesc,
I have a SQL Server 2008 table called users which stores users details. I
I have a history table where I log each request into a Web Handler
I have to write a query to database, that has such table: TABLE HISTORY:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.