如何在我的陈述中添加底线?
SELECT
AgentID,
PaymentAmount
FROM Table A
WHERE
DATEOFPAYMENT
GROUP BY
CollectorNumber
ORDER BY
CollectorNumber,
LastName,
DateofPayment,
PaymentAmount
如果DATEOFPAYMENT =昨天,那么PaymentAmount else 0为'前一天'
或
如果DATEOFPAYMENT = current_Month,那么PaymentAmount else 0为' MTD'
或
如果DATEOFPAYMENT = current_Year则PaymentAmount else 0为' YTD
答案 0 :(得分:0)
SELECT AgentID, PaymentAmount FROM Table A
WHERE CASE DATEOFPAYMENT
WHEN subdate(currentDate, 1) THEN PaymentAmount
WHEN month() THEN PaymentAmount
WHEN year() THEN PaymentAmount
ELSE 0
END
GROUP BY CollectorNumber
ORDER BY CollectorNumber, LastName, DateofPayment,
PaymentAmount
这几乎是伪代码,所以请修改语法。但案例陈述是这样的。