我有一个mysql的数据表,字段如下:id,type,mode,price。我想根据type和mode分组,分组后每组只显示一列,但是这一列我想要price最小的那条。这样写不对:select id,type,mode,min(price) from table1 group by type,mode拜托各位大侠了,救救小妹
select min(price) from table1 group by type,mode 哈哈我外行!
select * from (select * from 你的表名 order by price asc) T group by type,mode;
select min(price) from table1 group by type,mode ================================================ 听你的意思,要的是这种效果吗? 如果不能执行,可以用多条语句来写嘛!
select min(price),min(price) from table1 group by type,mode ================================================ 听你的意思,要的是这种效果吗? 如果不能执行,可以用多条语句来写嘛! ================================================= group by a ,b
a b c 1 2 5 1 3 7 1 2 10
select a,b,max(c) from 表 group by a,b 得到: 1 2 10 1 3 7
哈哈我外行!
================================================
听你的意思,要的是这种效果吗?
如果不能执行,可以用多条语句来写嘛!
================================================
听你的意思,要的是这种效果吗?
如果不能执行,可以用多条语句来写嘛!
=================================================
group by a ,b
a b c
1 2 5
1 3 7
1 2 10
select a,b,max(c) from 表 group by a,b
得到:
1 2 10
1 3 7
--就是先以a分组,再以b分组。