Count total number of records through query in axapta

To Count total number of records through query in axapta you can try following code in Ax job.

 
 Query        query = new Query();  
   QueryRun       queryRun;  
   QueryBuildDataSource qbds;  
   ;  
   qbds = query.addDataSource(tablenum(SalesTable));  
   queryRun = new QueryRun(query);  
   info(strfmt("Total Records in Salestable is %1",SysQuery::countTotal(queryRun)));  

you can get same thing by using select query also.

select count(recid) from salestable.