how to create the sub query in Ax

i want to select the last row value of the table in jobs

i have tried like sql sub query but its not working

for that i used this code

while select * from table_nameobj where table_nameobj.Id==(select count(id) from table_nameobj)

{

}

but this is produced error could u please help me

If you want to select the last row, just sort the data in reverse order and select the first line.

This would help you:

custtable ct; //Your table

;

select firstonly ct order by recid desc;

if(ct)

{

info(ct.AccountNum);

}