# Badge for using Search

**URL:** https://meta.discourse.org/t/badge-for-using-search/281545
**Category:** Data & reporting
**Tags:** search, sql-triggered-badge
**Created:** [September 3, 2023, 1:35pm UTC](https://meta.discourse.org/t/badge-for-using-search/281545 "2023-09-03T13:35:02Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![packman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/packman/32/289322_2.png) [@packman](https://meta.discourse.org/u/packman)
#### Post date: [September 3, 2023, 1:35pm UTC](https://meta.discourse.org/t/badge-for-using-search/281545/1 "2023-09-03T13:35:02Z")

</div>

To encourage the use of search on my forum I’ve created badges for using the search function. I’ve created three badges (First \>=1, Great \>=50 and Epic \>=200) but you can choose how many badges and the values for yourself.

```sql
SELECT user_id, min(created_at) AS granted_at 
FROM search_logs
WHERE user_id IS NOT NULL
GROUP BY user_id
HAVING count(*) >= ... --[! Add the number of times search used]

```
