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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T03:04:15+00:00 2026-05-18T03:04:15+00:00

So, the query I’m trying to make looks like this right now: SELECT `jid`,

  • 0

So, the query I’m trying to make looks like this right now:

SELECT `jid`, MAX(`start`) as `start` FROM `dates` WHERE `start` < NOW() GROUP BY `jid`

The table dates basically holds a DATETIME value start associated with a job.
As you probably guessed, jid is the id of a job, stored in another table.
A job can have many dates

What I’m trying to accomplish is to find out what jobs have all their start dates in the past.

My thought was to select the highest values of the start dates, grouped by jid and if they were in the past, it would imply that all other dates associated with the same job are also in the past.

This query isn’t working because it’s checking for start dates in the past and then selecting the highest of those. This doesn’t exclude the possibility of another date for the same job, lying in the future.

I have no idea how I could proceed now. Any help or clue is appreciated.

Cheers – Tom

  • 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-18T03:04:19+00:00Added an answer on May 18, 2026 at 3:04 am

    You have to use HAVING :

    SELECT jid, MAX(start) as start
    FROM dates
    GROUP BY jid
    HAVING MAX(start) < NOW();
    

    HAVING acts a bit like WHERE. It filters out the rows after they were selected. Usually (and actually, I can’t think of any other case), you only use HAVING with aggregate functions.

    (I hope you really inserted dates in the future in your table, though!)

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

Sidebar

Related Questions

This query: SELECT * FROM table WHERE field = 'EN' I would like to
Query: SELECT A.USER_ID, A.ROLE_ID, C.SUBGROUP, MAX(A.STATUS_ID) FROM USER_ROLE A, USER B, ROLE C WHERE
Query: SELECT StartDate, EndDate, RIGHT(Sector, 1 ) FROM Table1 ORDER BY Right(Sector, 1), StartDate
Query: select max(b.counter) as counter, b.m_group, b.m_code, a.s_id, s.id_sk from tbl_various a, tbl_map b,
This query: SELECT tbl_deliverable.*, user_to_deliverable.* where tbl_deliverable.id = user_to_deliverable.d_id returns this error from phpmyadmin:
Query: SELECT * FROM table WHERE fieldA LIKE '%%' AND fieldB LIKE '%%' AND
Query: SELECT TOP 1 ReportInvoked , EmailSent FROM tblReportInvoker WHERE WebUserId = 12345 This
Query: select distinct (Customer) ,CustomerID from history where Customer != '' and Customer LIKE
My query of interest is below SELECT COUNT(a.id) FROM users AS a RIGHT JOIN
Query 1: SET @sql2 = 'insert into TempReport select ID, max(TransactionTime),0 from ClubTransaction with

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.