我有一个这样的存储过程:
SELECT DISTINCT
C.cid
, C.custclientid
, C.client
, C.company
, C.product
, C.producttakendate
, C.total
, P.reciveamt
, P.dueamt
, (SELECT TOP 1 rcvdate
FROM paymentdata AS PD1
WHERE PD1.pclientid = PD.pclientid
AND PD1.productname = PD.productname
ORDER BY rcvdate DESC) AS rcvdate
, (SELECT TOP 1 nxtdate
FROM paymentdata AS PD1
WHERE PD1.pclientid = PD.pclientid
AND PD1.productname = PD.productname
ORDER BY rcvdate DESC) AS nxtdate
, (SELECT TOP 1 notepayment
FROM paymentdata AS PD1
WHERE PD1.pclientid = PD.pclientid
AND PD1.productname = PD.productname
ORDER BY rcvdate DESC) AS notepayment
FROM
customermaintenance C
LEFT OUTER JOIN
payment P ON C.custclientid = P.pclientid
LEFT OUTER JOIN
paymentdata PD ON P.pclientid = PD.pclientid
WHERE
C.custclientid = 1 AND C.product = 'Software'
我有datalist,有
<asp:Label ID="nextamountLabel" runat="server" Text='<%# Eval("dueamt") %>' />
我想放出dueamt = 5000
然后我在这个程序中如何计算?
答案 0 :(得分:2)
C.Total - COALESCE(p.reciveamt,0)
COALESCE在其参数
中返回它遇到的第一个非null