社区
Oracle 高级技术
帖子详情
查询一个表的一条记录
天涯海角的人
2007-08-13 11:05:12
我想查询一分组记录的全部记录;
比如:select max(score) from students group by name;
这只能查出max(score)的值,但我想查询此记录的其他字段的值,请问该如何做?
...全文
260
7
打赏
收藏
查询一个表的一条记录
我想查询一分组记录的全部记录; 比如:select max(score) from students group by name; 这只能查出max(score)的值,但我想查询此记录的其他字段的值,请问该如何做?
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
7 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
kinglht
2007-09-05
打赏
举报
回复
select * from students
where (name,score) in
(select name,max(score)
from students
group by name)
devise
2007-09-05
打赏
举报
回复
select a.* from students a,
(select name,max(score) score from students group by name) b
where a.name=b.name and a.score=b.score;
select * from students
where (name,score) in (select name,max(score) from students group by name);
devise
2007-09-05
打赏
举报
回复
select a.* from students a,
(select name,max(score) score from students group by name) b
where a.name=b.name and a.score=b.score;
ksrs
2007-08-28
打赏
举报
回复
select * from students
where (name,score) in
(select name,max(score)
from students
group by name)
tangjiyu
2007-08-17
打赏
举报
回复
修正
select * /* 多了一个列rk,去掉就列出详细列名 */ from
(select rank() over (partition by name order by score desc) as rk,t.* from students t)
where rk=1;
tangjiyu
2007-08-17
打赏
举报
回复
select * /* 多了一个列rk,去掉就列出详细列名 */ from
(select rank() over (partition by name order by score ) as rk,t.* from students t)
where rk=1;
子陌红尘
2007-08-13
打赏
举报
回复
select s.* from students s where not exists(select 1 from students where name=s.name and score>s.score)
select s.* from students s,(select name,max(score) as score from students group by name) v where s.name=b.name and s.score=v.score
MySQL
查询
与高级
查询
(多
表
、嵌套和正则
表
达式)
MySQL提供了功能强大、灵活的语句来实现这些操作,本章将介绍如何使用 SELECT 语句
查询
数据
表
中的一列或多列数据、使用集合函数显示
查询
结果、连接
查询
、子
查询
以及使用正则
表
达式进行
查询
等。 -------------------...
sql如何
查询
表
的第
一条
记录
和最后
一条
记录
sql如何
查询
表
的第
一条
记录
和最后
一条
记录
方法一:使用topselect TOP 1 * from apple;select TOP 1 * from apple order by id desc;(备注:top是Access的语法,MySQL不支持)方法二:使用LIMIT第
一条
记录
mysql> ...
mysql 查找最近
一条
记录
_关于mysql
查询
最近
一条
记录
关于mysql
查询
最近
一条
记录
最近项目中遇到需要
查询
记录
当前时间最近的
一条
记录
...="2017-03-29 19:30:36"order by time desclimit 1这样做虽然可以取出当前时间最近的
一条
记录
,但是一次
查询
需要将
表
遍历一遍,对于...
Mysql
查询
当前
记录
上
一条
与下
一条
记录
查询
当前
记录
上
一条
与下
一条
记录
的原理: 上
一条
的sql语句,从table
表
里按从大到小的顺序(正序ASC)选择
一条
比当前ID小的
记录
。 下
一条
的sql语句,从news
表
里按从小到大的顺序(倒序DESC)选择
一条
比当前ID大的...
Postgresql
查询
表
中最新的
一条
记录
根据证件号码分组
查询
表
中最新
一条
记录
Oracle 高级技术
3,492
社区成员
18,716
社区内容
发帖
与我相关
我的任务
Oracle 高级技术
Oracle 高级技术相关讨论专区
复制链接
扫一扫
分享
社区描述
Oracle 高级技术相关讨论专区
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章