mysql 学习笔记
2016-01-09 18:17
627 查看
mysql去重方法可以使用函数distinct或者group by :
(1) select distinct(customer_id) from user_table;
(2) select customer_id from user_table group by customer_id;
(3)拓展:查询某时间段登录的人数
select count(distinct(customer_id)) from login_logs where logtime......
left join使用例子:
select 20160102 AS logTime, count(regNum) as aa,platform from
(
select imei as regNum,operatingsystem as platform
from RegLogs_20160102
where operatingsystem >=1 and operatingsystem<=3
group by operatingsystem,regNum
) t1
left join
(
select imei as logNum
from LoginLogs_20160102
where operatingsystem >=1 and operatingsystem<=3
group by operatingsystem,logNum
) t2
on t1.regNum = t2.logNum where t1.regNum is not null and t2.logNum is not null
group by platform;
(1) select distinct(customer_id) from user_table;
(2) select customer_id from user_table group by customer_id;
(3)拓展:查询某时间段登录的人数
select count(distinct(customer_id)) from login_logs where logtime......
left join使用例子:
select 20160102 AS logTime, count(regNum) as aa,platform from
(
select imei as regNum,operatingsystem as platform
from RegLogs_20160102
where operatingsystem >=1 and operatingsystem<=3
group by operatingsystem,regNum
) t1
left join
(
select imei as logNum
from LoginLogs_20160102
where operatingsystem >=1 and operatingsystem<=3
group by operatingsystem,logNum
) t2
on t1.regNum = t2.logNum where t1.regNum is not null and t2.logNum is not null
group by platform;
相关文章推荐
- mysql 基本知识--约束以及修改数据表
- MYSQL 命令行显示乱码 解决方案
- mysql DQL exercise
- MYSQL 命令行显示乱码 解决方案
- mysql 找'最'的集合
- mysql常用语句(学习笔记)
- mysql-Innodb事务隔离级别-repeatable read详解(转)
- MySQL高级七——视图的使用
- Mysql MVCC详解
- MySQL单表百万数据记录分页性能优化 limit优化
- apparmor 引起自定义mysql 日志问题
- 解决远程连接MYSQL时无法连接的问题(Access denied for...)
- Mysql 远程登录
- MySQL高级六——函数创建和使用
- MySQL高级五——存储过程的管理
- mysql主从复制
- MySQL高级四——自定义条件和处理
- MySQL高级三——循环语句
- MySQL使用
- MySQL高级二——流程控制语句