Hello all,
I need to know how to join two tables together with their timestamps. The timestamps differ consistently by 1.8 seconds every time and there is a data entry every half hour. any ideas?
Hello all,
I need to know how to join two tables together with their timestamps. The timestamps differ consistently by 1.8 seconds every time and there is a data entry every half hour. any ideas?
This is a very weak link. They are consistently 1.8 seconds apart on that environment, but when you change anything, that can change.
If you must join by time stamp, generate the time stamp in code at the start of the commit, and set the timestamps to that value, so at the very least they are the same.
A better solution is to create a key to keep the data points together. Maybe a batchID if you are trying to tie together entries in the same half hour set.
This did the job:
SELECT * FROM db1.dataset, db2.dataset where extract(year from db1.dataset.timestamp) = extract(year from db2.dataset.timestamp)
and
extract(day from db1.dataset.timestamp) = extract(day from db2.dataset.timestamp)
and
extract(month from db1.dataset.timestamp) = extract(month from db2.dataset.timestamp)
and
extract(hour from db1.dataset.timestamp) = extract(hour from db2.dataset.timestamp)
and
extract(minute from db1.dataset.timestamp) <= extract(minute from db2.dataset.timestamp)+5
and
extract(minute from db1.dataset.timestamp) >= extract(minute from db2.dataset.timestamp)- 5