I extracted a temporary table by using the following query in mysql select player_id, obj_category from table order by player_id;
the output is as shown, each id is associated with multiple object categories
Current output
player_id | obj_category | created_time |
---|---|---|
19855. | Electronics | 2021-09-21 18:02:17 |
19855. | House. | 2021-09-21 18:03:20 |
19855. | Car. | 2021-09-21 18:03:54 |
19855. | Toys. | 2021-09-21 18:04:17 |
19855 | Sweets. | 2021-09-21 18:05:13 |
19907 | Business | 2021-09-21 15:02:17 |
19907 | Books. | 2021-09-21 15:02:40 |
19907 | House. | 2021-09-21 15:04:14 |
19907 | Books | 2021-09-21 15:05:34 |
19908 | Toys | 2021-09-21 14:04:17 |
19908 | Mobile | 2021-09-21 14:07:19 |
19908 | Sports | 2021-09-21 14:08:43 |
19908 | Electronics. | 2021-09-21 14:02:17 |
In this sample, i have 3 ids,(19855,19907,19908). I want to create a query where I would retrieve only the first 2 obj_category associated by each of the ids. They would be ordered according to the created time of each of the objects per each id
Expected output:
player_id | obj_category |
---|---|
19855. | Electronics |
19855. | House. |
19907 | Business |
19907 | Books |
19908 | Toys |
19908 | Mobile |
I tried multiple codes such as
, however i was not able to reach that output and i couldn't find any guidance to help me.
thank you in advance