After further though, I tried using a function:
CREATE OR REPLACE FUNCTION children ( ow integer, parent text) returns integer
AS $$
select count(*) as children from m where o = $1 and name ilike $2 || '/%';
$$
LANGUAGE sql;
An example call is:
select o, name, f1, f2, (select children(o,name) a
> "FB" == Frank Bax writes:
FB> It would help if you provided:
FB> a) statements to create sample data
FB> b) expected results from sample data
FB> Does this do what you want?
FB> select * from m, (SELECT count(*) AS nch FROM m WHERE o = (SELECT o
FB> FROM m WHERE id=30016) AND name ILIKE (
James Cloos wrote:
I have a table which includes a text column containing posix-style
paths. Ie, matching the regexp "^[^/]+(/[^/]+)*$".
I need to do a query of a number of columns from that table, plus the
count of rows which are "children" of the current row.
The query:
SELECT count(*) AS
I have a table which includes a text column containing posix-style
paths. Ie, matching the regexp "^[^/]+(/[^/]+)*$".
I need to do a query of a number of columns from that table, plus the
count of rows which are "children" of the current row.
The query:
SELECT count(*) AS nch FROM m WHERE o =