-- 1.自定义一个时间变量并设置为当前日期的前一天
SET @startTime = CONCAT(date_sub(curdate(),interval 1 day),'%');
-- 也可以从这里手动指定日期
-- SET @startTime = '2017-04-13%';
-- 显示要查询的日期
-- select @startTime;
select REPLACE(@startTime,'%','') as 日期,当日活跃用户,当日新增用户 from
(
-- 2.查询当日活跃用户
select '01' as id,count(1) as 当日活跃用户 from (
select DISTINCT uname from app_loginLog where logindate like @startTime
) as t
) as a,
-- 3.查询当日新增用户
(select '01' as id,count(1) as 当日新增用户 from app_user where registerdate like @startTime) b
where a.id = b.id;
mySql变量应用示例
猜你喜欢
转载自blog.51cto.com/1197822/2157669
今日推荐
周排行