You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2 lines
618 B
2 lines
618 B
select b."Id", b."TotalThreads", t.cnt from "Boards" b join (select "BoardId", count(*) cnt from "Threads" group by "BoardId") t on t."BoardId" = b."Id" where (select count(*) from "Boards" sb where sb."ParentBoardId" = b."Id") = 0 and b."TotalThreads" != t.cnt;
|
|
select b."Id", b."TotalThreads", sb.total, t.cnt, sb.total + t.cnt from "Boards" b join (select "ParentBoardId", sum("TotalThreads") total from "Boards" group by "ParentBoardId") sb on sb."ParentBoardId" = b."Id" join (select "BoardId", count(*) cnt from "Threads" group by "BoardId") t on t."BoardId" = b."Id" where b."TotalThreads" != sb.total+t.cnt;
|
|
|