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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:33:14+00:00 2026-05-30T20:33:14+00:00

Some data would be organized thusly: ID DATE COUNT1 COUNT2 A 20120101 1 2

  • 0

Some data would be organized thusly:

ID DATE COUNT1 COUNT2 
A  20120101 1    2
A  20120201 2    2
B  20120101 3    0
C  20111201 1    0
C  20120301 2    2 

Another table has ID NAME

               A MYNAME
              .... etc

i want to return a table of

ID NAME COUNT COUNT2

for the most recent available piece of data, i.e. the january count for A is not included

i know I need to use HAVING, INNER JOIN, and GROUP BY but every iteration I can come up with has an error.

  • 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-30T20:33:15+00:00Added an answer on May 30, 2026 at 8:33 pm

    If you only want rows with the date equal to the global maximum date, just use a subquery:

    select ID,DATE,COUNT1,COUNT2
    from table
    where DATE=(select max(DATE) from table);
    

    If you want the maximum date per ID, then you can use a self join:

    select ID,MAX_DATE,COUNT1,COUNT2
    from(
        select ID,max(DATE) as MAX_DATE
        from table
        group by ID
    )a
    join(
        select ID,DATE,COUNT1,COUNT2
        from table
    )b
    on (a.ID=b.ID and a.MAX_DATE=b.DATE);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an Excel table with some data that I would like to export
I have an excel sheet which has some huge data. Data is organized as
I have some data that I would like to visualize. Each byte of the
I would like to add some data to the body of a http request
I would like to update some data with JSON when the user clicks on
I would like to create a file which stores some data that can be
I have some data in .cvs. I would like to make a simple barplot
I have some data with a timestamp in SQL Server, I would like to
I have some data analysis that needs to perform. On average, it would involve
I want to write a program to hash some data and preferably i would

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.