[code]SELECT *
FROM (SELECT t0.FBILLNO FBILLNO,
t0.FDATE FDATE,
t0.FSUPPLIERID FSUPPLIERID_ID,
t0.FDOCUMENTSTATUS FDOCUMENTSTATUS,
t0.FPURCHASEORGID FPURCHASEORGID_ID,
t0.FCLOSESTATUS FCLOSESTATUS,
t3.FMATERIALID FMATERIALID_ID,
t3.FUNITID FUNITID_ID,
t3.FQTY FQTY,
t3_D.FDELIVERYDATE FDELIVERYDATE,
t3.FGIVEAWAY FGIVEAWAY,
t3.FMRPCLOSESTATUS FMRPCLOSESTATUS,
t0.FBILLTYPEID FBILLTYPEID,
t0.FPURCHASEORGID FPURCHASEORGID,
t0.FOBJECTTYPEID FOBJECTTYPEID,
t0.FID FID,
t3.FENTRYID T3_FENTRYID,
t3.FSeq T3_FSEQ,
ROW_NUMBER() OVER(ORDER BY t0.FCREATEDATE DESC, t0.FBILLNO DESC, t3.FSeq ASC) FIDENTITYID
FROM t_PUR_POOrder T0
LEFT OUTER JOIN t_PUR_POOrderEntry T3
ON t0.FID = t3.FID
LEFT OUTER JOIN t_PUR_POOrderEntry_D T3_D
ON t3.FENTRYID = t3_D.FENTRYID
WHERE ((t0.FPURCHASEORGID IN (1, 100007, 100008)) AND
(((t0.FPURCHASEORGID IN (1, 0)) AND
t0.FOBJECTTYPEID = 'PUR_PurchaseOrder') AND
t1.FPAYCONDITIONID = '20001'))) TLIST
WHERE ((fidentityid >= 1) AND (fidentityid <= 200))
[/code]
推荐阅读