"SELECT (iif((select count(*) from billjbcn_local where a.jobnumber=jobnumber and a.containertype=containertype)=1,1,
(select count(*) from billjbcn_local where a.jobnumber and a.containertype=containertype and a.id>id)+1)) AS linenumber, * INTO newtabled
FROM billjbcn_local AS a;
"