我的表格JobOrder
有5列:( jo_no
,jo_type
,jo_release
,jo_date
,jo_livedate
)
使用下面的MySQL查询,我正在计算jo_type
:
select jo_no, jo_date, jo_livedate, count(*) from joborder
where jo_no='1232';
输出:
+-------+-----------+-------------+----------+
| jo_no | jo_date | jo_livedate | count(*) |
+-------+-----------+-------------+----------+
| 1232 | 01-dec-14 | 05-dec-14 | 5 |
+-------+-----------+-------------+----------+
我想输出jo_date
和jo_livedate
的差异。如果差异是5天,我需要生成5条记录,如下所示......
+-------+-----------+-------------+
| jo_no | date | count(*)** |
+-------+-----------+-------------+
| 1232 | 01-dec-14 | 5 |
+-------+-----------+-------------+
| 1232 | 02-dec-14 | 5 |
+-------+-----------+-------------+
| 1232 | 03-dec-14 | 5 |
+-------+-----------+-------------+
| 1232 | 04-dec-14 | 5 |
+-------+-----------+-------------+
| 1232 | 05-dec-14 | 5 |
+-------+-----------+-------------+