P*******b 发帖数: 1001 | 1 Given a table:
TABLE
Cust ID, Order ID, Date
Retrieve the customer who has ordered on two days ie., say 1st and 10th.
Also, is your query the most optimal one. | l*****a 发帖数: 559 | 2 SELECT `CustID` FROM `TABLE` group by `CustID` having count('Date')=2
在mysql里跑过。 | A*H 发帖数: 127 | 3 你这个结果包括date在同一天的
【在 l*****a 的大作中提到】 : SELECT `CustID` FROM `TABLE` group by `CustID` having count('Date')=2 : 在mysql里跑过。
| A*H 发帖数: 127 | 4 如果是mysql 5, 可以用having count(distinct(date))=2 |
|