I have a table like this:
ID Type UserID Timestamp
1 1 1000 1312389223
2 1 1000 1312389220
3 2 1000 1312389215
4 3 1000 1312389213
5 3 2000 1312389205
6 1 2000 1312389201
7 2 1000 1312389190
What I need now, is to retrieve only certain parts of the data in this table. The list shows data in relation to what a certain user has been doing on my site.
Some of the “Type”‘s need to have all entries shown. Others need only to have the most recent shown.
In the above example I need to have all occurances of Type = 2 shown, but only top 1 (ordered by Timestamp) of Type = 1 shown. Same goes for Type = 3. This is per UserID basis.
Hope I have explained myself clear enough.
Thanks in advance for your help,
fischer.
Simple and quick solution if you dont need IDs
That will keep IDs, but it’s more complicated and somewhat slower:
Anyway, both solutions are not very scalable