我
我有一个小问题,我每天匹配一些文件来更新我的数据库。我想数一下我从1个月开始每天在我的表“订单”上以"GOB“开始的订单数量。
id|last_update
gogo2132|27/08/2013 00:00:00
gob00000|27/08/2013 00:00:00
gob00001|27/08/2013 00:00:00
gob00002|27/08/2013 00:00:00
gob00003|28/08/2013 00:00:00我需要的结果
Day|count"only id start by gob)
27/08/2013| 3
28/08/2013| 1谢谢
发布于 2013-08-31 00:32:16
我认为你正在遵循代码。
Select count(*),order_date From Table
Where Left(id,3) = 'Gob' And DateDiff(d,order_date,getdate()) <= 30
Group by order_date发布于 2013-08-31 00:25:09
SELECT orderdate, COUNT(*)
FROM `ORDER`
WHERE orderid LIKE 'GOB%'
GROUP BY orderdate
ORDER BY orderdate DESC如果orderdate不包含时间,这将是一天的计数。
发布于 2013-08-31 00:33:27
SELECT orderdate, COUNT(*)
FROM `ORDER`
WHERE orderid LIKE 'gob%' AND last_update= (SELECT NOW() - INTERVAL 1 MONTH)
GROUP BY DAY(last_update)https://stackoverflow.com/questions/18537421
复制相似问题