如何獲取客戶已申請了多少天?
圖片告訴我想要得到什麼。我不知道如何在mysql中總結日期,任何一個都有幫助?
需要php來完成這些工作嗎?
如何獲得客戶通過郵寄的天數?
select ? from table where ?
如何獲取客戶已申請了多少天?
圖片告訴我想要得到什麼。我不知道如何在mysql中總結日期,任何一個都有幫助?
需要php來完成這些工作嗎?
如何獲得客戶通過郵寄的天數?
select ? from table where ?
SELECT customers_id, SUM(customers_id) as sum_days FROM table GROUP BY customers_id, DAY(date);
應該這樣做。
非常感謝你,很好的回答 – linjuming 2013-03-02 05:50:18
這是我的猜測:
SELECT `customers_id`, COUNT(DISTINCT(`date`)) as sum_days
FROM `table` GROUP BY `customers_id`
我試圖在一個小桌子,我擺弄並得到了以下幾點:
SELECT author, entry_date FROM table;
+--------+------------+
| author | entry_date |
+--------+------------+
| 5 | 0000-00-00 |
| 8 | 0000-00-00 |
| 8 | 0000-00-00 |
| 8 | 2013-02-28 |
| 8 | 2013-02-28 |
| 8 | 2013-03-02 |
+--------+------------+
田田
SELECT author, COUNT(DISTINCT(entry_date)) as num_days
FROM table GROUP BY author ;
+--------+----------+
| author | num_days |
+--------+----------+
| 5 | 1 |
| 8 | 3 |
+--------+----------+
2 rows in set (0.00 sec)
此外,這是前一個回覆在我的同桌上的結果:
SELECT author, SUM(author) as sum_days FROM table
GROUP BY author, DAY(entry_date);
+--------+----------+
| author | sum_days |
+--------+----------+
| 5 | 5 |
| 8 | 16 |
| 8 | 8 |
| 8 | 16 |
+--------+----------+
4 rows in set (0.00 sec)
非常感謝你 – linjuming 2013-03-04 01:00:53
你嘗試過什麼嗎?如果是這樣給我們的起點。 – 2013-03-02 05:07:19
我不擅長mysql,我不知道如何嘗試 – linjuming 2013-03-02 05:49:54