Jump to content

Please help with query


leetee

Recommended Posts

I have the below query which pulls out what I want with one expection and I would be grateful if anyone can suggest how to solve it.

 

The joblist is the main table which links to the events table.  A job_id can be entered into the events table many times.  I need to pull out all job ids that are entered into the events list but only pull out each distinct job which was the most recent entry (according to the date).  At the moment, the query is pulling out the earliest job_id entered into the events table.

 

SELECT j.id,j.jobref,DATE_FORMAT(e.date, '%m/%Y') AS date FROM joblist as j
INNER JOIN events as e ON j.id=e.job_id
WHERE e.status_id = '9'
GROUP BY j.jobref
ORDER by j.jobref

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.