// $results = \Drupal::database()->query("SELECT COUNT(DISTINCT(ac.clickid)) AS clicks, u.uid AS uid, u.name AS name, u.data AS data, aa.payouts_owed AS payouts_owed
// FROM {affiliate_clicks} ac INNER JOIN {users} u ON ac.uid = u.uid INNER JOIN {affiliate} aa ON u.uid = aa.uid WHERE aa.active = 1 AND ac.click_time > :time_limit
// GROUP BY uid ORDER BY clicks DESC", array(":time_limit" => $time_limit));
$results=\Drupal::database()->query("SELECT COUNT(DISTINCT(ac.clickid)) AS clicks, u.uid AS uid, u.name AS name, u.data AS data, aa.payouts_owed AS payouts_owed FROM {affiliate_clicks} ac INNER JOIN {users} u ON ac.uid = u.uid INNER JOIN {affiliate} aa ON u.uid = aa.uid WHERE aa.active = 1 AND ac.click_time > :time_limit GROUP BY uid ORDER BY clicks DESC",array(":time_limit"=>$time_limit));
'#markup'=>l(t('View affiliate history'),"user/$account->uid/affiliate",array('attributes'=>array('title'=>t('View affiliate information and history for !username',array('!username'=>format_username($account)))))),
'#markup' => Link::fromTextAndUrl(t('View affiliate history'), "user/$account->uid/affiliate", array('attributes' => array('title' => t('View affiliate information and history for !username', array('!username' => $account))))),