fixed query

This commit is contained in:
2024-06-07 10:10:03 +02:00
parent 614f393463
commit acb779de7e

View File

@@ -45,8 +45,8 @@ public class Routes {
posts.postdate, posts.postdate,
posts.postlocation[0] AS longitude, posts.postlocation[0] AS longitude,
posts.postlocation[1] AS latitude, posts.postlocation[1] AS latitude,
(SELECT count(*) FROM reaction WHERE reaction.post = posts.id AND positive = TRUE) AS positive, (SELECT count(*) FROM reactions WHERE reaction.post = posts.id AND positive = TRUE) AS positive,
(SELECT count(*) FROM reaction WHERE reaction.post = posts.id AND positive = FALSE) AS negative (SELECT count(*) FROM reactions WHERE reaction.post = posts.id AND positive = FALSE) AS negative
FROM FROM
posts posts
WHERE WHERE
@@ -66,8 +66,8 @@ public class Routes {
com.postdate, com.postdate,
com.postlocation[0], com.postlocation[0],
com.postlocation[1], com.postlocation[1],
(SELECT count(*) FROM reaction WHERE reaction.post = com.child AND positive = TRUE) AS positive, (SELECT count(*) FROM reactions WHERE reaction.post = com.child AND positive = TRUE) AS positive,
(SELECT count(*) FROM reaction WHERE reaction.post = com.child AND positive = FALSE) AS negative (SELECT count(*) FROM reactions WHERE reaction.post = com.child AND positive = FALSE) AS negative
FROM FROM
(SELECT * FROM comments inner join posts ON comments.child = posts.id) com (SELECT * FROM comments inner join posts ON comments.child = posts.id) com
inner join targets ON targets.id = com.parent inner join targets ON targets.id = com.parent