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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T03:27:55+00:00 2026-06-19T03:27:55+00:00

Note: I am a little new to SQL Server, so this should be an

  • 0

Note: I am a little new to SQL Server, so this should be an easy question, and I apologize for mistakes in formatting this question.

This is SQL Server 2008 R2.

I have two tables.

  • Table 1: DATA has key ID and columns PROD_ID, COLLECT_TS

  • Table 2: PRODUCT has key PROD_ID and column PROD_NAME

I want my query to list every PROD_NAME by the latest COLLECT_TS

Here is what I have thus far:

SELECT MAX(COLLECT_TS), PROD_ID
FROM dbo.SG_DATA
GROUP by PROD_ID

This successfully returns all the latest COLLECT_TS with a PROD_ID, but the PROD_ID is just a number and doesn’t mean anything to the user.

Thanks in advance for your answers.

  • 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-06-19T03:27:56+00:00Added an answer on June 19, 2026 at 3:27 am
    Select max(p.prod_name) as prod_name, max(d.collect_ts) as collect_ts
    From product p
    Join data d -- left join if you want products with no data
        On d.prod_id = p.prod_id
    Group by p.prod_id
    

    The idea is to join products and data so we get one row for each data entry with the extra information from products attached. Then we group by product id and take the max collect ts from each group. We also take the max name, but that’s ok because name will be constant across the group, so we just need some aggregation to select a single value.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

NOTE: This is a followup to my question here. I have a program that
Note : Before asking this question I did an exhaustive search, and found little
EDIT: Note to new Perl programmers : This mechanism should NOT be used for
Note, this is not a duplicate of .prop() vs .attr() ; that question refers
(Note: This is not a question about what is the best way with code
Note: Not sure if this is the right stack, please tell if I should
We have a web server handling requests from clients. One component of this web
Note: I'm new to version numbering. Please excuse my ignorance. I have a project
NOTE: This is a long question. I've explained all the 'basics' at the top
Note: I'm not completely sure if this question really belongs to StackOverflow so feel

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.