| 54 | == За секое прашање кое е поставено во BlogPostForConsultations колку одговори има, од кои корисници се дадени одговорите и каква е улогата на корисниците кои одговориле(admin, manager, employee, standard). |
| 55 | {{{ |
| 56 | SELECT |
| 57 | bpc.ID AS question_id, |
| 58 | bpc.title AS question_title, |
| 59 | COUNT(bpa.ID) AS number_of_answers, |
| 60 | u."name" AS user_name, |
| 61 | r.type AS user_role |
| 62 | FROM |
| 63 | project.blog_post_for_consultations bpc |
| 64 | JOIN |
| 65 | project.blog_post_answers bpa ON bpc.ID = bpa.blogpostconsid |
| 66 | JOIN |
| 67 | project.users u ON bpa.usersID = u.ID |
| 68 | JOIN |
| 69 | project.roles r ON u.role_id = r.ID |
| 70 | GROUP BY |
| 71 | bpc.ID, u.ID, r.ID -- Include the role ID in the GROUP BY clause |
| 72 | ORDER BY |
| 73 | bpc.ID; |
| 74 | }}} |