Posted by rjleigh on January 4, 2011 at 7:43am
I have a custom module that records a specific module status history per node. The table has several fields, but here the important ones are nid, a timestamp field and a status text field.
My module just keeps adding to the table to keep the full history of changes.
If I wanted to use an SQL call to view the latest entry for each nid, I'd use:
SELECT a.nid , a.timestampfield, a.textfield
FROM (
SELECT nid, MAX(timestampfield) as maxtime
FROM mytable
GROUP BY nid
) as b
INNER JOIN mytable
AS a
ON a.nid = b.nid
AND a.timestampfield = b.maxtime;Is there any way to express this kind of join in hook_views_data?