To Count total number of records through query in axapta you can try following code in Ax job.
you can get same thing by using select query also.
select count(recid) from salestable.
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.