I'm trying to select a query with a subquery that selects the delta between 2 timestamp fields.
For example Delta = Timestamp N - timestamp N-1
select
T_event.Actie_ID, actie_omschrijving, event_timestamp,
left(custom1,4) as model, custom1, Custom2,
(select B.event_timestamp - A.event_timestamp
from t_event A,
t_event B
where B.Event_ID = A.Event_ID-1)
from
T_event
inner join
T_Actie on T_event.Actie_ID = T_Actie.Actie_ID
where
T_EVENT.Actie_ID in (48, 49, 43, 31, 36)
and Event_Timestamp >= '2019-07-22'
order by
Event_timestamp desc
This is the error I get:
Msg 512, Level 16, State 1, Line 1
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.