| 127 | WHERE |
| 128 | /* |
| 129 | LIMIT the query to select only the first x records |
| 130 | ordered by most_recent_action, but include all the |
| 131 | ties for the last place. |
| 132 | |
| 133 | This allows us to filter the query using |
| 134 | most_recent_action > last_most_recent_action |
| 135 | as opposed to most_recent_action >= last_most_recent_action, |
| 136 | which would start to fail if there were more than x |
| 137 | records with a most_recent_action of last_most_recent_action. |
| 138 | */ |
| 139 | mra.most_recent_action IN ( |
| 140 | SELECT DISTINCT most_recent_action |
| 141 | FROM ( |
| 142 | SELECT |
| 143 | interview_id |
| 144 | , MAX(date_time) most_recent_action |
| 145 | FROM action |
| 146 | GROUP BY interview_id |
| 147 | WHERE date_time > '01-jan-2000' /* last_most_recent_action */ |
| 148 | ORDER BY MAX(date_time) ASC |
| 149 | LIMIT 10 |
| 150 | ) adf |
| 151 | ) |