SQL Query temporanea


Esempio

Si comportano allo stesso modo delle subquery nidificate ma con una sintassi diversa.

WITH ReadyCars AS (
  SELECT *
  FROM Cars
  WHERE Status = 'READY'
)
SELECT ID, Model, TotalCost
FROM ReadyCars
ORDER BY TotalCost;
ID Modello Costo totale
1 Ford F-150 200
2 Ford F-150 230

Sintassi di subquery equivalente

SELECT ID, Model, TotalCost
FROM (
  SELECT *
  FROM Cars
  WHERE Status = 'READY'
) AS ReadyCars
ORDER BY TotalCost