Pager disappears when adding "GROUP BY" in the SQL query Drupal pager disappears when I add GROUP BY to the query.

This code works.

$countSql = "SELECT  COUNT(*) FROM journal ";
$sql = "SELECT  * FROM journal";    

$result = pager_query($sql, 1, 0, null, $countSql);
theme_pager(NULL, 10)


This code doesn't show the pager.

$countSql = "SELECT  COUNT(*) FROM journal ";
$sql = "SELECT  * FROM journal GROUP BY id";

$result = pager_query($sql, 1, 0, null, $countSql);  
theme_pager(NULL, 10)


What is it wrong with the latter code?
Your query with the GROUP BY is incorrect, MySQL is lax enough to let you write this kind of queries but it is by no way recommended. When you use a GROUP BY clause you should group all the columns without an aggregate function.

Also if you put a GROUP BY in your query, you should also include it in your count query. Generally a brutal way to make the count query is to put it this way:

$sql = "SELECT  * FROM journal";
$countSql = "SELECT  COUNT(*) FROM ($sql) ";


Try to modify your queries and amend your question with further precisions.