Changes between Version 28 and Version 29 of Onyx to CiviCRM


Ignore:
Timestamp:
01/07/14 09:28:09 (11 years ago)
Author:
Richard Bramley
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Onyx to CiviCRM

    v28 v29  
    125125    GROUP BY interview_id
    126126    ) mra ON mra.interview_id = i.id
     127WHERE
     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    )
    127152ORDER BY mra.most_recent_action ASC
    128153;