Jump to content

finding the greatest timestamp in an sql table


stubarny

Recommended Posts

Hi,

 

I have a table of factfiles on my database.

 

In another table in the same database I have a list of factfile updates - including the id number of the factfile and the timestamp of when the update occured. If a factfile has been updated 60 times then there will be 60 records in this table.

 

I now want to create a list of factfiles that have been updated with the most recently updated at the top. So I have the following SQL code:

 

$query ="SELECT article_id FROM article_updates ORDER BY timestamp_of_update ASC";

 

Please could you tell me how to modify this code so that I only return one record for each different value of article_id? And also please could you tell me

how to ignore all updates for a given factfile within 7 days of the first update of a given factfile (to stop notifications of article updates appearing more than once per a week for a given factfile).

 

(so if an article is first updated on Monday and then on the Wednesday, Thursday, Saturday and following Tuesday the update notification should only appear on the first Monday and the following Tuesday).

 

Thanks,

 

Stu

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.