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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:12:48+00:00 2026-05-25T16:12:48+00:00

I have a table with items that are part of a thread, so they

  • 0

I have a table with items that are part of a thread, so they have a thread ID, each item also has a date (UNIX timestamp). My table looks something like the following (UNIX timestamps simplified):

+-----------------------------+
|  id |   date  |  thread_id  |
+-----+---------+-------------+
|  1  |   1111  |      4      |
|  2  |   1333  |      4      |
|  3  |   1444  |      5      |
|  4  |   1666  |      5      |
+-----------------------------+

What I want to do is select thread IDs where ALL the items sharing the same thread ID are smaller than the passed date. So if I wanted thread IDs where ALL items are older than 1555 (date < 1555), I would only expect to have thread ID 4 returned, not 5 even though it’s got an item with a date smaller than 1555. This is what I tried:

SELECT * FROM table WHERE date < 1555 GROUP BY thread_id ORDER BY date DESC

What I’m trying to do with that query is group all items by thread ID around the item with the highest date value and from there get the items where the date is less than 1555. But that doesn’t work, it will still return thread ID 5 because it’s got an item older than 1555.

So to summarize, how would I only select thread IDs where ALL items are older than a certain date?

  • 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-25T16:12:49+00:00Added an answer on May 25, 2026 at 4:12 pm
    SELECT thread_id FROM table GROUP BY thread_id HAVING MAX(date) < 1555
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table full of items that each have a unique ItemID .
let's say that I have a table called Items (ID int, Done int, Total
I have a following table using MVC that shows number of items the user
I have a recordset loop that creates a table, and every 9 items it
I have a History Table in SQL Server that basically tracks an item through
I have 3 tables, - Section table that defines some general item sections. -
I have a html-table, that has a header, that is supposed to be clickable
I have a table of pairwise distances of items. Given an Item ID I
I have an Items table that contains a CategoryId field. This is an FK
I have a table of items that users are allowed to vote on. In

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.