# Trendige Suchbegriffe ohne Admin/Moderator-Suchen?

**URL:** <https://meta.discourse.org/t/trending-search-terms-with-admin-moderator-searches-removed/316002>\
**Category:** Data & reporting\
**Created:** [11. Juli 2024 um 20:03 UTC](https://meta.discourse.org/t/trending-search-terms-with-admin-moderator-searches-removed/316002 "2024-07-11T20:03:36Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Lilly](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lilly/32/575047_2.png) [@Lilly](https://meta.discourse.org/u/Lilly)\
**Post date:** [15. Juli 2024 um 10:51 UTC](https://meta.discourse.org/t/trending-search-terms-with-admin-moderator-searches-removed/316002/2 "2024-07-15T10:51:21Z")

</div>

Hallo @Kieran_Berryman 👋

Hmmm, vielleicht probieren Sie das mal? 🤔

```sql
--[params]
-- date :start_date
-- date :end_date

WITH admin_moderator_users AS (
    SELECT 
        gu.user_id
    FROM 
        group_users gu
    JOIN 
        groups g ON gu.group_id = g.id
    WHERE 
        g.name IN ('admins', 'moderators')
)

SELECT 
    lower(sl.term) AS search_term,
    count(sl.id) AS term_count,
    (COALESCE(SUM(CASE WHEN sl.search_result_type IS NULL THEN 0 ELSE 1 END), 0) / count(sl.id)::float) * 100 AS click_through_rate,
    SUM(CASE WHEN sl.search_result_type IS NULL THEN 0 ELSE 1 END) as click_count
FROM 
    search_logs sl
LEFT JOIN 
    admin_moderator_users amu ON sl.user_id = amu.user_id
WHERE 
    sl.created_at::date BETWEEN :start_date AND :end_date
    AND amu.user_id IS NULL
GROUP BY 
    lower(sl.term)
ORDER BY 
    term_count DESC

```

* * *

Hier ist die SQL für den Dashboard-Bericht „Trending Search Terms“:

> [@Dashboard Report - Trending Search Terms](https://meta.discourse.org/t/dashboard-report-trending-search-terms/288562/1):
>
> This is an SQL version of the Dashboard Report for Trending Search Terms. This report provides insight into the search terms used on a site within a specified date range, and helps understand which terms are most frequently searched for and how often users click on the search results. --[params] -- date :start\_date -- date :end\_date SELECT lower(term) AS search\_term, count(id) AS term\_count, (COALESCE(SUM(CASE WHEN search\_result\_type IS NULL THEN 0 ELSE 1 END), 0) / count(id)::float) \* 10…

---

_[View the full topic](https://meta.discourse.org/t/trending-search-terms-with-admin-moderator-searches-removed/316002)._
