SELECT
e.cust_id AS customer_id,
e.event_id AS event_id,
max(t.updatedON) as recent_timestamp
FROM
event_table AS e
INNER JOIN car AS c ON e.cust_id = c.cust_id and e.event_id = c.event_id
INNER JOIN walk AS w ON e.cust_id = w.cust_id and e.event_id = w.event_id
CROSS APPLY (values(c.updated_On),(w.updated_on)) as t(updatedOn)
group by e.cust_id, e.event_id
Error: An error occurred while checking the query syntax. Errors: The values(values(c.updated_On table has a multi-part specification. This is not allowed. values(values(c.updated_On is not a known data extension or system data view. You can only query existing data extensions or system data views.
The three data extensions event_table
, car
and walk
do exist. Any ideas what i can do to resolve?
EDIT: Included sample data and desired output here.
EDIT 2: The accepted answer below is correct and should remain for helping others. Since the implementation however changed OUTER APPLY
to act as INNER JOIN
, I did some cleaning:
SELECT e.cust_id, e.event_id,
CASE
WHEN
car.updated_on >= motorcycle.updated_on and car.updated_on >= walk.updated_on
THEN car.updated_on
WHEN motorcycle.updated_on >= car.updated_on
THEN motorcycle.updated_on
ELSE walk.updated_on
END as updated_on
FROM
event_table AS e
INNER JOIN car AS car ON e.cust_id = car.cust_id
INNER JOIN motorcycle AS motorcycle ON e.cust_id = motorcycle.cust_id
INNER JOIN walk AS walk ON e.cust_id = walk.cust_id
WHERE
e.event_id = car.event_id
AND e.event_id = motorcycle.event_id
AND e.event_id = walk.event_id
values
is not supported in SFMC.Automation Studio > Query Activity
. All i want to do is get theGREATEST
date of three columns and i can't figure out how :(car.updatedON
,walk.updatedOn
and __?motorcycle.updatedOn
, sorry. I simplified it for easier example. Same structure as the other two tables. Just one more complexity to since there's 3 tables to consider instead of two.Car, Motorcycle and Walk