How to db_select DISTINCT on a particular field in Drupal 7?
Assuming you're trying to get to roughly this query:

SELECT DISTINCT e.nid AS nid, e.time AS time, n.type AS type, n.status AS status, n.title AS title
FROM 
{my_table} e
INNER JOIN {node} n ON n.nid = e.nid
GROUP BY e.time
ORDER BY e.time ASC


You would use:

$query = db_select('my_table', 'e')
  -&gt;distinct()
  -&gt;fields('e', array('nid', 'time', 'foo', 'bar'))
  -&gt;fields('n', array('type', 'status', 'title'))
  -&gt;groupBy('e.time')
  -&gt;orderBy('e.time');

$query-&gt;join('node', 'n', 'n.nid = e.nid');