WITH a AS ( SELECT * FROM a ), b AS ( SELECT * FROM b -- ココ。↑のa bがそのまま使える。 ), c AS ( SELECT * FROM a WHERE id IN (SELECT id FROM b) ) SELECT COUNT(1) FROM a INNER JOIN b ON a.id = b.id
WITH句の中で、前に定義したWITH句のテーブルが使える。
WITH a AS ( SELECT * FROM a ), b AS ( SELECT * FROM b -- ココ。↑のa bがそのまま使える。 ), c AS ( SELECT * FROM a WHERE id IN (SELECT id FROM b) ) SELECT COUNT(1) FROM a INNER JOIN b ON a.id = b.id
WITH句の中で、前に定義したWITH句のテーブルが使える。