Roger, Try using the fields position on the output; which in this case, the Order By statment would read like this: Order by 30, Imdsc1 Be aware that any change to the order of the preceeding fields will require a re-designation of the field number. In case you don't understand why you have this problem, it's because Odytid is not a field on the output record, that position -could be- Odytid, but it could also be the unnamed field value of blank. Bill "Roger"
wrote in message news:2283a6af.-1@WebX.WawyahGHajS... > I am trying to use the following select statement but when I try to run it it gives me a error. (ORDER BY column ODYTID or expression not in result table.) > > SELECT Sddoco, Sddcto, Sdkcoo, Sdmcu, Sditm, Sdlitm, Sdlnid, > Sdurcd, Sdlprc, Sdsoqs, Sdivd, Sdurat, Sddoc, Sdstop, Sdrout, > Sdshan, Sddeln, Sddftn, Sdlprc, Sduprc, Sduorg, Sdlocn, > Imrvno, Imdsc1, Imlitm, Imuom1, Imitm, Imsrp5, Imurrf, > ifnull(Odytid,' '), ifnull(Odyccd,0) FROM F4211 inner join F4101 > on Sditm = Imitm left outer join F5642103 on Sddoco = Oddoco > and Sditm = Oditm and Sdlnid = Odlnid WHERE Odyccd = ? and > Odytid <> ? ORDER BY Odytid, Imdsc1