Create pager from db_query
You want to take advantage of the PagerDefault class.

Write your query as a db_select query which I'll leave as an exercise for the reader because, frankly, I'm not sure if it's possible to create a db_select query with a subquery as part of an expression like that :).  Assuming you build up your select query in a variable called $query, you'd have code along these lines:

$query = db_select('REPORT_LIST_VIEW')-&gt;extend('PagerDefault');
...build up $query object here...
$res = $query-&gt;execute();

$pager = drupal_render(array('#theme' =&gt; 'pager'));


Then just output $pager wherever you want it.

Also, in general, I'd recommend placing this in a block rather than hard-coding it into your theme so that it's more reusable.