简体   繁体   English

每天的SQL计数上限(计数字符串)

[英]SQL count max (count string) from each day

I have table like this http://pastebin.com/raw.php?i=miEpLUNU Every 30mins I'm inserting wind directions. 我每隔30分钟就有这样的表格http://pastebin.com/raw.php?i=miEpLUNU我要插入风向。 Now what I want to do is I would like to do something like this but for each day and each station. 现在我想做的就是我想做这样的事,但每天和每个站都要做。

SELECT DIR_GORYCZKOWA, COUNT(*) AS COUNT_DIR, DATE_FORMAT(DATE_SYSTEM, '%Y-%m-%d') AS DATE 
FROM wind_direction
WHERE DATE_SYSTEM BETWEEN '2014-02-19' AND '2014-02-20'
GROUP BY DIR_GORYCZKOWA ORDER BY COUNT_DIR DESC LIMIT 1;

Is this even possible? 这有可能吗?

Try that: 试试看:

 SELECT DIR_GORYCZKOWA, COUNT(*) AS COUNT_DIR, DATE_FORMAT(DATE_SYSTEM, '%Y-%m-%d') AS  DATE 
 FROM wind_direction
 GROUP BY DATE(DATE_SYSTEM)
 ORDER BY COUNT_DIR DESC LIMIT 1;

echo_Me's answer is correct assuming that the station is stored in column "DIR_GORYCZKOWA". 假设该电台存储在“ DIR_GORYCZKOWA”列中,则echo_Me的答案是正确的。 Keep the where clause if you want to limit the data returned to a certain date range. 如果您想将返回的数据限制为某个日期范围,请保留where子句。

The query returning these results is correct http://pastebin.com/raw.php?i=QX2MGR5c 返回这些结果的查询是正确的http://pastebin.com/raw.php?i=QX2MGR5c

This is giving you the total count per station (DIR_GORYCZKOWA) per day 这是每天的每个站点的总数(DIR_GORYCZKOWA)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM