Doc: fix example of recursive query.

Compute total number of sub-parts correctly, per jason@banfelder.net

Simon Riggs

Discussion: https://postgr.es/m/166161184718.1235920.6304070286124217754@wrigleys.postgresql.org
This commit is contained in:
Tom Lane 2022-08-28 10:44:52 -04:00
parent f8e70cfb8f
commit 25ddf59e4b
1 changed files with 1 additions and 1 deletions

View File

@ -2133,7 +2133,7 @@ SELECT sum(n) FROM t;
WITH RECURSIVE included_parts(sub_part, part, quantity) AS (
SELECT sub_part, part, quantity FROM parts WHERE part = 'our_product'
UNION ALL
SELECT p.sub_part, p.part, p.quantity
SELECT p.sub_part, p.part, p.quantity * pr.quantity
FROM included_parts pr, parts p
WHERE p.part = pr.sub_part
)