我有会员表
member_Id
member_Firstname
另一张表Paymentschedules
paymentschedule_Id
member_Id
paymentschedule_amountdue values(100 rs,200rs)
paymentschedule_amonutpaid values (30 rs,40 rs)
paymentschedule_ActualDatetobepaid values(2011-02-03,2011-02-01,2011-03-01)
paymentschedule_ datepaid values like(2011-09-12,2011-08-10,2011-11-12,2010-08-01)
我的问题是,我是否可以将“逾期”的成员名字视为“今天”,并考虑到这些值“ActualDatetobepaid”和“amonutpaid”,“amountdue”和“datepaid”
任何人都可以帮助这个
答案 0 :(得分:2)
不确定我理解列的含义,但试试这个:
select distinct member_Firstname
from member m
join Paymentscedules p on p.member_id = m.member_id
where paymentschedule_ActualDatetobepaid<now() and paymentschedule_amountdue > paymentschedule_amonutpaid
如果您可以为该列和列含义提供数据类型用户,我可以提出更精确的解决方案。
答案 1 :(得分:2)
您的上一次请求“添加7天”,通过在J0HN的解决方案中添加7天来解决:
SELECT DISTINCT member_Firstname
FROM member m
JOIN Paymentscedules p ON p.member_id = m.member_id
WHERE DATE_ADD(paymentschedule_ActualDatetobepaid, INTERVAL 7 DAY)< NOW()
AND paymentschedule_amountdue > paymentschedule_amonutpaid