0

I would like to calculate SUM value in time for all items in a table "measures", which contains measures from stations (each one defined with an identifier)

_ id_station (varchar)
_ measure_time (timestamp)
_ measure_value (float)

My goal is to create a graph of the sum for all stations measures in time (1 sum for each day with at least 1 measure of 1 station) The issue is that stations are not synchronized and to calculate the sum for each day of the year, I need to take for each station the closest value in the past.

How to solve this? Many thanks.

New contributor
Nicolas VILA is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
5
  • 2
    Please consider following these suggestions.
    – mustaccio
    Commented Jul 9 at 14:16
  • Take a look at the date_bin() function. That's what you need to put in the GROUP BY clause. Commented Jul 9 at 14:49
  • Thanks, I will check that. Commented Jul 9 at 15:31
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
    – Community Bot
    Commented Jul 10 at 6:11
  • Hi, and welcome to dba.se! Kindly construct a fiddle (dbfiddle.uk) with your table(s), sample data and a desired result!
    – Vérace
    Commented Jul 11 at 13:00

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.