我想从表bannertatclick中提取总点击时间(如周明智或月份),其中bannerstatclick表具有这些列(idBannerStats:integer,Time:Timestamp,idCampaignBanner:char(36))。我想将最大时间计算为当前日期,然后在30天之前计算,然后查找此日期范围之间的点击次数,它将不会返回任何输出...
SELECT count(idCampaignBanner) AS TotalClicks
FROM newradium.BannerStatsClick
WHERE Time BETWEEN
(Select max(`Time`) FROM newradium.BannerStatsClick)
And
(select max(`Time`)- INTERVAL 30 DAY FROM newradium.BannerStatsClick);
答案 0 :(得分:0)
试试这个
set @max_time:= (SELECT max(`Time`) FROM newradium.BannerStatsClick );
SELECT count(idCampaignBanner) AS TotalClicks
FROM newradium.BannerStatsClick
WHERE Time BETWEEN date_add(@max_time, INTERVAL 30 DAY) and @max_time;
答案 1 :(得分:0)
set @max_time:= (SELECT max(`Time`) FROM newradium.BannerStatsClick );
SELECT count(idCampaignBanner) AS TotalClicks
FROM newradium.BannerStatsClick
WHERE Time BETWEEN dateadd(day,-30,@max_time) and @max_time