0

I am trying to query my database to obtain future timestamp predictions illustrated in the column 'RRP'. The future timestamps are represented by the 'INTERVAL_DATETIME' column. Where my current query is as follows:

select `RUN_DATETIME`, `INTERVAL_DATETIME`, `REGIONID`, `RRP`
from mms.p5min_regionsolution
where REGIONID = 'SA1'
order by INTERVAL_DATETIME desc limit 100

However, as you can see in the figure below, there are usually multiple duplications of the INTERVAL_DATETIME column and consequently the RRP column. How can I edit my query so that I only get the most recent duplication of the INTERVAL_DATETIME column and RRP and disregard the others. I have also included the RUN_DATETIME column if this can be used in any way. Database layout

  • @astentx, not really unfortunately, in that question they had an additional column with a group ID, I only have the timestamps column which is dynamically updating in comparison to a static group ID. – WorkerGuy21 Jun 21 '21 at 00:55
  • You need first (top 1) record per timestamp (grouped results), so `row_number() over(partition by , interval_datetime order by run_datetime desc)`. Or I didn't get the logic. – astentx Jun 21 '21 at 00:59
  • How about distinct? – togi Jun 21 '21 at 01:02
  • what does `select version();` say? – ysth Jun 21 '21 at 01:38

0 Answers0