# Accepted Solutions Query

**URL:** https://meta.discourse.org/t/accepted-solutions-query/372514
**Category:** Data & reporting
**Tags:** sql-query, reporting
**Created:** [July 1, 2025, 10:19pm UTC](https://meta.discourse.org/t/accepted-solutions-query/372514 "2025-07-01T22:19:48Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Shreyas\_Kulkarni](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/shreyas_kulkarni/32/510405_2.png) [@Shreyas\_Kulkarni](https://meta.discourse.org/u/Shreyas_Kulkarni)
#### Post date: [July 1, 2025, 10:19pm UTC](https://meta.discourse.org/t/accepted-solutions-query/372514/1 "2025-07-01T22:19:48Z")

</div>

Hi, I am using the following query to check accepted solutions this month. However, I do not see data past March. Additionally, these numbers do not match what is shown on the Accepted solutions Report. Could I get some guidance here on what I’m doing wrong?

```plaintext
SELECT DISTINCT 
YEAR(p.created_at), MONTH(p.created_at), 
count(distinct(p.topic_id))
    FROM posts p
    JOIN posts_custom_fields pcf ON pcf.post_id = p.id
    WHERE (pcf.name = 'is_accepted_answer' AND pcf.value = 'true') AND YEAR(p.created_at) = 2025
    GROUP BY 1,2

```

---

<div class="post-metadata">

### Author: ![SaraDev](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/saradev/32/335139_2.png) [@SaraDev](https://meta.discourse.org/u/SaraDev)
#### Post date: [July 1, 2025, 10:46pm UTC](https://meta.discourse.org/t/accepted-solutions-query/372514/2 "2025-07-01T22:46:48Z")

</div>

Hi Shreyas,

Looking at the query you’ve shared, the reason you’re not seeing data past March and that the numbers in your query don’t match the [Accepted Solutions Dashboard Report](https://meta.discourse.org/t/dashboard-report-accepted-solutions/288863) is because you’re using the `posts_custom_fields` database table, however, the Discourse Solved plugin tracks accepted solutions in using `discourse_solved_solved_topics` table.

As of March, 2025, there was a [change](https://github.com/discourse/discourse-solved/pull/352) that updated the Discourse Solved plugin to use the `discourse_solved_solved_topics` database table to determine solved topics on your Discourse site, and this table is now the source of truth for all solution data.

Here’s a corrected version of your query that will match the Accepted Solutions Report, and show you data for 2025.

**Accepted solutions by month for 2025**

```sql
SELECT 
    EXTRACT(YEAR FROM p.created_at) AS year,
    EXTRACT(MONTH FROM p.created_at) AS month,
    TO_CHAR(p.created_at, 'Month') AS month_name,
    COUNT(DISTINCT dst.topic_id) AS solutions_count
FROM discourse_solved_solved_topics dst
JOIN posts p ON p.id = dst.answer_post_id
WHERE p.created_at >= '2025-01-01' AND p.created_at < '2026-01-01'
GROUP BY 1, 2, 3
ORDER BY year, month

```

The results for this query will include:

- All months in 2025 that have accepted solutions (not just March)
- Numbers that match the Accepted Solutions Report because it’s using the same underlying database table
- Date formatting using PostgreSQL’s native functions

I hope this helps you find the data you’re looking for! 🙂

---

<div class="post-metadata">

### Author: ![Shreyas\_Kulkarni](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/shreyas_kulkarni/32/510405_2.png) [@Shreyas\_Kulkarni](https://meta.discourse.org/u/Shreyas_Kulkarni)
#### Post date: [July 3, 2025, 6:14pm UTC](https://meta.discourse.org/t/accepted-solutions-query/372514/3 "2025-07-03T18:14:18Z")

</div>

Thank you @SaraDev! This is helpful. I will check the output of this query once I am able to get discourse\_solved\_solved\_topics in Snowflake to query.
