SELECT 'card' AS component
, 'Volume by Expendature and Quantity' AS title
, 2 AS columns
;
SELECT 'volume/Expense.sql?_sqlpage_embed' AS embed
, '' AS footer
WHERE EXISTS (SELECT 1 FROM sqlpage_txn LIMIT 1);

SELECT 'volume/Quantity.sql?unit='||$unit_mass||'&_sqlpage_embed' AS embed
, '' AS footer
WHERE EXISTS (SELECT 1 FROM sqlpage_txn WHERE unit = $unit_mass LIMIT 1)
;

SELECT 'volume/Quantity.sql?unit='||$unit_volume||'&_sqlpage_embed' AS embed
, '' AS footer
WHERE EXISTS (SELECT 1 FROM sqlpage_txn WHERE unit = $unit_volume LIMIT 1)
;

SET unit_count_chart = (SELECT v#>>'{}' FROM json_array_elements($unit_count::json) j(v) LIMIT 1);
SELECT 'volume/Quantity.sql?unit='||$unit_count_chart||'&_sqlpage_embed' AS embed
, '' AS footer
WHERE EXISTS (SELECT 1 FROM sqlpage_txn WHERE unit = $unit_count_chart LIMIT 1)
AND (SELECT count(DISTINCT v#>>'{}') FROM json_array_elements($unit_count::json) j(v)) == 1
;
