In the following table of data:
I am trying to select from this table the records that are distinct based off of the columns itemable_id
, itemable_type
, and user_id
. I also want the records sorted by last_viewed_at
. In rails, I have been able to get the records to be distinct, but every way I try always gets record ID 1
instead of 4
for ThingType1
that has itemable_id 32
. Essentially, the record set iI'm trying to end up with is one with rows with IDs 4, 3, and 2. How can i do this efficiently?