用友U8查询采购订单明细可付款申请金额

SELECT * FROM  dbo.PO_Pomain WHERE cPOID='IPO201116010'

SELECT ID FROM  dbo.PO_Podetails WHERE POID='1000002351' AND cInvCode='CE0070030183'

SELECT  PO_Podetails.iNatSum, --采购订单本币价税合计
         --  @AppForPo =
    (
        SELECT SUM(AP_ApplyPayVouchs.iApplyAmt)
        FROM AP_ApplyPayVouchs
            JOIN dbo.AP_ApplyPayVouch
                ON AP_ApplyPayVouchs.PID = AP_ApplyPayVouch.PID
                   AND AP_ApplyPayVouch.cSource = '采购订单'
        WHERE AP_ApplyPayVouchs.iBVid = PO_Podetails.ID
             -- AND AP_ApplyPayVouchs.AutoID != @AutoID
    ) AS AppForPo,                                      --付款申请单参照采购订单已申请金额
           --@AppForBill =
    (
        SELECT SUM(AP_ApplyPayVouchs.iApplyAmt)
        FROM dbo.AP_ApplyPayVouch
            JOIN dbo.AP_ApplyPayVouchs
                ON AP_ApplyPayVouchs.PID = AP_ApplyPayVouch.PID
                   AND AP_ApplyPayVouch.cSource = '采购发票'
        WHERE AP_ApplyPayVouchs.iPOsID = PO_Podetails.ID
             -- AND AP_ApplyPayVouchs.AutoID != @AutoID
    )     AS AppForBill                                  --付款申请单参照采购发票已申请金额
    FROM dbo.PO_Pomain
        JOIN dbo.PO_Podetails
            ON PO_Podetails.POID = PO_Pomain.POID
    WHERE PO_Podetails.ID IN('1000020722','1000020740','1000020752','1000020769','1000020781','1000020793','1000020807','1000020827','1000020843','1000020856','1000020870','1000020890')

你可能感兴趣的:(用友,sql,数据库)