sql语句是
INSERT INTO t_source_type_transfer(logdate,time, Host, CountryCode, RegionCode,City, SourceIP, Hits, cdn_id, CityName ,type)
select b.logdate,b.time,b.Host,b.CountryCode, b.RegionCode,b.City, b.SourceIP, b.Hits, b.cdn_id, b.CityName ,b.type
from t_source_type as b
ON DUPLICATE KEY UPDATE Hits=t_source_type.Hits+b.Hits;
t_source_type
中的时间字段为 14:35:21
如何在使用该声明时将其更改为 14:35:00 ?
谢谢!
答案 0 :(得分:0)
我认为使用maketime()
可以更清晰地向下舍入到最近的分钟:
INSERT INTO t_source_type_transfer(logdate, time, Host, CountryCode, RegionCode, City, SourceIP, Hits, cdn_id, CityName, type)
select b.logdate,
maketime(hour(b.time), minute(b.time), 0),
b.Host, b.CountryCode, b.RegionCode, b.City, b.SourceIP, b.Hits, b.cdn_id, b.CityName ,b.type
from t_source_type b
ON DUPLICATE KEY UPDATE Hits=t_source_type.Hits+b.Hits;
对此的微小变化也适用于许多分钟 - 例如5分钟或30分钟。