How can I run the following query in PostgreSQL (the following should work on MSSQL). The purpose is to see how much time apart to evens happened:
select ABS(CAST((a.timefield - b.timefield) as INT)) as 'Time Apart'
from a inner join b on (a.id = b.id);
Depending on the type of “a.timefield” and “b.timefield” this should work: