SQL examples
Inspect the actual SQL, returned values, and PostgreSQL column types from the comparison fixtures.
LATERAL join
The subquery computes a total for each customer.
SELECT c.cust, t.total FROM (SELECT DISTINCT cust FROM inv) c JOIN LATERAL (SELECT sum(amount) AS total FROM inv i WHERE i.cust=c.cust) t ON true ORDER BY 1 Recorded results
SELECT 2 | # | custtext | totalnumeric |
|---|---|---|
| 1 | acme | 80.25 |
| 2 | beta | 0.00 |
These examples use saved replay results. Run your own query or see the full comparison.