| 4 | | SELECT |
| 5 | | bpc.id AS consultation_id, |
| 6 | | bpc.date_askes AS claim_date, |
| 7 | | bpc.title AS consultation_title, |
| 8 | | bpc.description AS consultation_description, |
| 9 | | u.id AS user_id, |
| 10 | | u.name AS user_name, |
| 11 | | COUNT(bpa.id) AS answers_count |
| 12 | | FROM |
| 13 | | project.blog_post_for_consultations bpc |
| 14 | | LEFT JOIN |
| 15 | | project.users u ON bpc.users_id = u.id |
| 16 | | LEFT JOIN |
| 17 | | project.blog_post_answers bpa ON bpc.id = bpa.blogpostconsid |
| 18 | | WHERE |
| 19 | | bpc.date_askes >= current_date - interval '6 months' |
| 20 | | GROUP BY |
| 21 | | bpc.id, bpc.date_askes, bpc.title, bpc.description, u.id, u.name |
| 22 | | ORDER BY |
| 23 | | answers_count DESC |
| 24 | | LIMIT 1; |
| 25 | | |
| | 4 | SELECT |
| | 5 | bpc.id AS consultation_id, |
| | 6 | bpc.date_askes AS claim_date, |
| | 7 | bpc.title AS consultation_title, |
| | 8 | bpc.description AS consultation_description, |
| | 9 | u.id AS user_id, |
| | 10 | u.name AS user_name, |
| | 11 | COUNT(bpa.id) AS answers_count |
| | 12 | FROM |
| | 13 | project.blog_post_for_consultations bpc |
| | 14 | LEFT JOIN |
| | 15 | project.users u ON bpc.users_id = u.id |
| | 16 | LEFT JOIN |
| | 17 | project.blog_post_answers bpa ON bpc.id = bpa.blogpostconsid |
| | 18 | WHERE |
| | 19 | bpc.date_askes >= current_date - interval '6 months' |
| | 20 | GROUP BY |
| | 21 | bpc.id, bpc.date_askes, bpc.title, bpc.description, u.id, u.name |
| | 22 | ORDER BY |
| | 23 | answers_count DESC; |