发布网友 发布时间:2022-04-09 07:09
共5个回答
懂视网 时间:2022-04-09 11:30
from scott.emp e, (select e.deptno, max(e.sal) sal from scott.emp e group by e.deptno) me where e.deptno = me.deptno and e.sal = me.sal;2.查找某个表 lampa 按字段evno分组,求字段inte的最大值
select * from lampa a where 1>(select count(*) from lampa where a.evno=evno and a.inte<inte)
获取数据库分组后的最大值
标签:
热心网友 时间:2022-04-09 08:38
插入测试记录:
[sql] view plain copy
insert into students values('数学','Jack','Tianjin',80)
insert into students values('数学','Jordan','Tianjin',80)
insert into students values('数学','James','Beijing',55)
insert into students values('英语','Jack','Tianjin',90)
insert into students values('英语','Jordan','Tianjin',60)
insert into students values('英语','James','Beijing',100)
insert into students values('语文','Jack','Tianjin',60)
insert into students values('语文','Tom','Tianjin',77)
insert into students values('语文','Jordan','Tianjin',68)
想要抓取每个科目第一名的整条信息,可以使用Row_number()函数:
select *
from (
select course,stu_name,city,score,ROW_NUMBER() over(partition by course order by score desc) as rn
from students
) a
where a.rn <=1;
热心网友 时间:2022-04-09 09:56
分组查询,查询出每组数据的数量
select count(*) from table group by xx
以上一个sql为结果集,查询出最大的数量
select max(xx) from (select count(*) from table group by xx ) a
a是取的别名
xx是你分组的表的列名
table换成表名
热心网友 时间:2022-04-09 11:31
用子查询啊热心网友 时间:2022-04-09 13:22
select max(count(字段)) from 表名称 where 条件追问报错,好像不能套用