An alternative to UBB.threads
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.
 
 
 
 
FLocal/Resources/FLocal/sql/find-wrong-board-posts-coun...

2 lines
640 B

select b."Id", b."TotalPosts", t.total from "Boards" b join (select "BoardId", sum("TotalPosts") total 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."TotalPosts" != t.total;
select b."Id", b."TotalPosts", sb.total, t.total, sb.total + t.total from "Boards" b join (select "ParentBoardId", sum("TotalPosts") total from "Boards" group by "ParentBoardId") sb on sb."ParentBoardId" = b."Id" join (select "BoardId", sum("TotalPosts") total from "Threads" group by "BoardId") t on t."BoardId" = b."Id" where b."TotalPosts" != sb.total+t.total;