Highest appearance of a value within each group
问题 I'm having a table with an user-ID and the Webside-IDs he navigated through. The table looks like this: | user-ID | website-ID | | 1 | 1 | | 1 | 2 | | 1 | 1 | | 1 | 4 | | 2 | 1 | | 2 | 2 | | 2 | 5 | | 2 | 2 | I'd like to select the website-ID each user has been into the most. As you can see, a min , max or avg won't work here. Any ideas? 回答1: This may look complicated but it will only aggregate the data once only , then pass through it ranking the results and choosing only the first one