0

In MS SQL Server i have a query like this:

SELECT  *
FROM tableA
OUTER APPLY (SELECT TOP 1 * FROM tableB 
WHERE tableB.dateTimeColumn < tableA.dateTimeColumn ORDER BY tableB.dateTimeColumn DESC)

How i can have the same result in BigQuery due to the lack of OUTER APPLY?

marchiosim
  • 119
  • 1
  • 10

1 Answers1

0

Per this documentation, your query would be like this:

SELECT *
FROM tableA
LEFT JOIN (
  SELECT *
  FROM tableB
  WHERE tableB.dateTimeColumn < tableA.dateTimeColumn
  ORDER BY tableB.dateTimeColumn DESC
  LIMIT 1
) AS tableB ON true;
Joevanie
  • 489
  • 2
  • 5