# Can we export like record wrt to Users?

**URL:** https://meta.discourse.org/t/can-we-export-like-record-wrt-to-users/263638
**Category:** Data & reporting
**Tags:** sql-query
**Created:** [May 3, 2023, 4:08am UTC](https://meta.discourse.org/t/can-we-export-like-record-wrt-to-users/263638 "2023-05-03T04:08:43Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Anamika](https://avatars.discourse-cdn.com/v4/letter/a/67e7ee/32.png) [@Anamika](https://meta.discourse.org/u/Anamika)
#### Post date: [May 3, 2023, 4:08am UTC](https://meta.discourse.org/t/can-we-export-like-record-wrt-to-users/263638/1 "2023-05-03T04:08:43Z")

</div>

How can I export the data for users like wrt to a post or discussion? The information required will include user ID, post or topic id and the like.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [May 3, 2023, 8:08am UTC](https://meta.discourse.org/t/can-we-export-like-record-wrt-to-users/263638/2 "2023-05-03T08:08:24Z")

</div>

What do you want? The user record for every user who has posted in a topic?

---

<div class="post-metadata">

### Author: ![Anamika](https://avatars.discourse-cdn.com/v4/letter/a/67e7ee/32.png) [@Anamika](https://meta.discourse.org/u/Anamika)
#### Post date: [May 28, 2023, 9:52am UTC](https://meta.discourse.org/t/can-we-export-like-record-wrt-to-users/263638/3 "2023-05-28T09:52:37Z")

</div>

Yes, to review which user has liked which post or topic

---

<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: [May 28, 2023, 10:00am UTC](https://meta.discourse.org/t/can-we-export-like-record-wrt-to-users/263638/4 "2023-05-28T10:00:48Z")

</div>

This should be possible using something like:

```sql
-- [params]
-- topic_id :topic_id
-- int :post_number

SELECT pa.created_at::date,
       pa.user_id
FROM post_actions pa
JOIN posts p ON p.id = pa.post_id
WHERE p.topic_id = :topic_id
  AND p.post_number = :post_number
  AND pa.post_action_type_id = 2
ORDER BY pa.created_at DESC

```

That one would be for an individual post, giving a list of users who liked it and when.
