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 943331
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T22:25:19+00:00 2026-05-15T22:25:19+00:00

I have a table for contents on a page. The page is divided into

  • 0

I have a table for contents on a page. The page is divided into sections.
I want to get the last version for each page-section.

Id (int)
Version (int)
SectionID

Id    Version    SectionID    Content
1       1           1           AAA
2       2           1           BBB
3       1           2           CCC
4       2           2           DDD
5       3           2           EEE

I want to get:

Id    Version    SectionID    Content
2       2           1           BBB
5       3           2           EEE
  • 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-15T22:25:20+00:00Added an answer on May 15, 2026 at 10:25 pm

    You could use an exclusive self join:

    select  last.*
    from    YourTable last
    left join
            YourTable new
    on      new.SectionID = last.SectionID
            and new.Version > last.Version
    where   new.Id is null
    

    The where statement basically says: where there is no newer version of this row.

    Slightly more readable, but often slower, is a not exists condition:

    select  *
    from    YourTable yt
    where   not exists
            (
            select  *
            from    YourTable yt2
            where   yt2.SectionID = yt.SectionID
                    and yt2.Version > yt.Version
            )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have stored page contents (tables, plain text, images and paragraphs) into a variable.
I have a table of contents in my page (see here ) with these
I have a jsp page which shows the contents of a table. While the
I have a page search in development here on the Table of Contents tab:
On one HTML Page ( From.htm ) I have: <table class=Contents Stylize General> <tr>
I have a <code>rich:extendedDataTable</code>. Each row has a a4j:commandLink as below. Table Page: <a4j:commandLink
In my page i have many table cells. Inside each cell i have one
I have a table contents many fields db.define_table('i2l_templates', Field('id','id', represent=lambda id:SPAN(A(T('View'),_href=URL('view_template',args=id)),' | ', A(T('Edit'),_href=URL('edit_template',args=id)))),
I have a table with contents that look similar to this: id | title
I have a recursive function reading a table of contents of documents from a

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.