SELECT TOP (1)
COMPANYIMAGE.REFRECID, COMPANYIMAGE.IMAGE, COMPANYIMAGE.REFRECID AS Expr1,
EMPLTABLE.EMPLID, SYSCOMPANYUSERINFO.USERID,
DIRPARTYTABLE.NAME, EMPLTABLE.TITLE
FROM
COMPANYIMAGE INNER JOIN
EMPLTABLE ON COMPANYIMAGE.REFRECID = EMPLTABLE.RECID INNER JOIN
SYSCOMPANYUSERINFO ON EMPLTABLE.EMPLID = SYSCOMPANYUSERINFO.EMPLID INNER
JOIN
WORKFLOWTRACKINGTABLE ON SYSCOMPANYUSERINFO.USERID =
WORKFLOWTRACKINGTABLE.USER_ INNER JOIN
DIRPARTYTABLE ON EMPLTABLE.PARTYID = DIRPARTYTABLE.PARTYID INNER JOIN
PURCHTABLE ON WORKFLOWTRACKINGTABLE.CONTEXTRECID = PURCHTABLE.RECID
WHERE (COMPANYIMAGE.DATAAREAID = ‘Ceu’) AND
(PURCHTABLE.PURCHID = ‘12345’) AND (WORKFLOWTRACKINGTABLE.CONTEXTTABLEID = 345)
AND
(WORKFLOWTRACKINGTABLE.TRACKINGCONTEXT = 5) AND
(WORKFLOWTRACKINGTABLE.TRACKINGTYPE = 4)
ORDER BY WORKFLOWTRACKINGTABLE.DUEDATETIME DESC