educative.io

Inner query execution

How many times will the inner query SELECT MAX(LastUpdatedOn) FROM DigitalAsset run? Only once or once per row for the outer query?

SELECT FirstName 

FROM Actors 

INNER JOIN DigitalAssets 

ON ActorId = Id 

WHERE LastUpdatedOn = (SELECT MAX(LastUpdatedOn) 
    FROM DigitalAssets);

Hi @lienji_second,

SELECT MAX(LastUpdatedOn) FROM DigitalAsset query runs once. we don’t run this query for each row. It extracts the entry that has the most recent activity from all the rows.