标签:group by code 语句 模糊查询 group and 递增 between car
select * from car where time > ‘2016-09-01‘
--模糊查询
select * from car where name like ‘奥迪%‘
--排序查询
select * from car order by oil desc --递减
select * from car order by oil asc --递增(默认)
select * from car order by oil , powers desc
--去重查询
select distinct brand from car
--分组查询
select brand from car group by brand
--聚合函数
select brand,COUNT(*) from car group by brand
select brand,AVG(oil) from car group by brand
select brand,max(oil) from car group by brand
select brand,min(oil) from car group by brand
select brand,sum(oil) from car group by brand
select brand,(max(oil)+min(oil))/2 from car group by brand
--select brand,avg(oil) from car
--group by brand having oil > AVG(oil)
--子查询
select * from car where brand in(‘b001‘,‘b002‘,‘b003‘)
select * from car where brand in(
select brand from car where name like ‘%奥迪%‘)
select * from car where price between 30 and 50
--别名
select ids as ID,code as ‘编码‘,name ‘名字‘,brand
from car
标签:group by code 语句 模糊查询 group and 递增 between car
原文地址:http://www.cnblogs.com/gbbwzz/p/7724278.html