【发布时间】:2016-09-10 06:14:32
【问题描述】:
这是我的 2 个 mysql 表。在clients 表中显示用户连接日期,在clients_pay_bill 表中显示用户从连接日期 (conn_date) 开始支付账单的月份。
a) 客户
clients_id conn_date
=======================
1 2016-06-01
2 2016-07-17
3 2016-06-22
4 2016-09-03
b)clients_pay_bill
cpp_id clients_id paid_month
===================================
1 1 2016-07-03
2 2 2016-07-22
3 4 2016-09-09
4 2 2016-07-22
现在我想显示所有月份s,其中包含在当前日期之前未向客户付款的天数和月份。
例如:
clients_id = 1 连接日期 (conn_date) 是 2016-06-01,他到目前为止只支付了 2016-07-03 个月的账单。所以sql查询会在下个月输出:
2016-06
2016-08
2016-09
**2016-07 will not print because he already paid this months bill**
我还想显示天数和月数,例如:3 个月的某些天..
我无法想象 sql 查询应该是什么样子?
【问题讨论】: