# Запрос в Data Explorer для событий?

**URL:** <https://meta.discourse.org/t/data-explorer-query-for-events/272536>\
**Category:** Data & reporting\
**Tags:** events, sql-query\
**Created:** [23.Июль.2023 05:05:14 UTC](https://meta.discourse.org/t/data-explorer-query-for-events/272536 "2023-07-23T05:05:14Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)\
**Post date:** [23.Июль.2023 18:42:34 UTC](https://meta.discourse.org/t/data-explorer-query-for-events/272536/5 "2023-07-23T18:42:34Z")

</div>

Чтобы сделать код чуть более читаемым и не запоминать все коды, можно добавить что-то вроде этого:

```sql

-- [params]
-- topic_id :topic_id

SELECT ei.user_id,
      CASE 
       WHEN ei.status = 0 THEN 'Иду' 
       WHEN ei.status = 1 THEN 'Заинтересован'
       WHEN ei.status = 2 THEN 'Не пойду' 
        END AS "Идёте?"
FROM discourse_post_event_invitees ei
JOIN posts p ON p.id = ei.post_id 
WHERE p.topic_id = :topic_id
ORDER BY ei.status

```

---

_[View the full topic](https://meta.discourse.org/t/data-explorer-query-for-events/272536)._
