我正忙着为一个我正在做的项目完成一个问题而且为了我的生活,我很难过。
问题如下: Roxanne被告知每天为每一部逾期的电影向ZAR5客户收费。编写将在tblRentals中包含过期金额的列的SQL查询,并显示报告。
我已经尝试过一些东西,但我对SQL很新,但还没有找到解决方法。这是我尝试使用的代码,但它不会为每个过期电影创建新列或显示金额* 5 ..请帮助!!
SELECT CustomerID, DateReturned, DueDate
From tblRentals
WHERE
((DateReturned>DueDate)*5) AS OverdueAmount
答案 0 :(得分:2)
对于Oracle:
SELECT
CustomerID,
DateReturned,
DueDate,
(DateReturned - DueDate)*5 as OverdueAmount
From
tblRentals
WHERE
DateReturned > DueDate and DateReturned Is NoT Null
对于MySQL:
将(DateReturned - DueDate)*5
更改为DATEDIFF(DateReturned, DueDate)*5