|
@@ -1,14 +1,5 @@
|
|
DROP TABLE IF EXISTS sqlpage_products;
|
|
DROP TABLE IF EXISTS sqlpage_products;
|
|
CREATE TABLE IF NOT EXISTS sqlpage_products AS
|
|
CREATE TABLE IF NOT EXISTS sqlpage_products AS
|
|
---(
|
|
|
|
--- "Products" int,
|
|
|
|
--- "Categories" int,
|
|
|
|
--- "Groups" int,
|
|
|
|
--- product text,
|
|
|
|
--- category text,
|
|
|
|
--- "group" text
|
|
|
|
--- );
|
|
|
|
---INSERT INTO sqlpage_products
|
|
|
|
SELECT
|
|
SELECT
|
|
count(DISTINCT p.id) AS "Products",
|
|
count(DISTINCT p.id) AS "Products",
|
|
count(DISTINCT c.id) AS "Categories",
|
|
count(DISTINCT c.id) AS "Categories",
|
|
@@ -27,3 +18,4 @@ AND
|
|
(g.name IN (SELECT v#>>'{}' FROM json_array_elements($groups::json) j(v)) OR $groups IS NULL)
|
|
(g.name IN (SELECT v#>>'{}' FROM json_array_elements($groups::json) j(v)) OR $groups IS NULL)
|
|
GROUP BY ROLLUP ("group", category, product)
|
|
GROUP BY ROLLUP ("group", category, product)
|
|
;
|
|
;
|
|
|
|
+GRANT SELECT ON sqlpage_products TO PUBLIC;
|