--生长发育表growth--
create table Growth(
Growth_Id integer primary key, --发育表表单号
Growth_StuId integer, --学员id
Growth_Stature number, --身高
Growth_Sit number, --坐高
Growth_Head number, --头围
Growth_Circumference number, --胸围
Growth_Avoirdupois number, --体重
Growth_Eye number, --视力
Growth_Time date, --测量时间
Re varchar2(50) --备注
);--学生表--
stu_id integer,
stu_name varchar2(50)
--班级表--
class_id integer,
class_name varchar2(50)我想查询某一个班级里的所有学生的生长发育信息,
每个学生只显示一个记录,就是测量时间最后的一条.弄了一天还是没弄出来,用的是oracle数据库,请各位前辈帮帮忙!
create table Growth(
Growth_Id integer primary key, --发育表表单号
Growth_StuId integer, --学员id
Growth_Stature number, --身高
Growth_Sit number, --坐高
Growth_Head number, --头围
Growth_Circumference number, --胸围
Growth_Avoirdupois number, --体重
Growth_Eye number, --视力
Growth_Time date, --测量时间
Re varchar2(50) --备注
);--学生表--
stu_id integer,
stu_name varchar2(50)
--班级表--
class_id integer,
class_name varchar2(50)我想查询某一个班级里的所有学生的生长发育信息,
每个学生只显示一个记录,就是测量时间最后的一条.弄了一天还是没弄出来,用的是oracle数据库,请各位前辈帮帮忙!
解决方案 »
- 移动了归档日志文件,怎么更新它的位置?
- 【满分求解】win7 64位操作系统如何安装64位ORACLE
- java职位要求:有处理海量数据的能力,有高并发的经验,我该为面试准备哪些方面的工作
- 关于utl_raw.cast_to_number
- 关于ORACLE PORTAL 问题.
- oracle 备份求助
- 我怎么再没有安装oracle的情况下远程管理我的数据库?
- 我想在触发器中得到对当前表的SQL操作的内容,应该如何实现??v$sql视图中有相关的信息,如何提取??
- 请教一下客户端远程连接Oracle速度慢的问题
- 关于DBWR与commit的问题
- 存储过程看不懂!!! 谁能帮我详细说明下
- 在安装oracle数据库软件时,遇到的与数据库监听程序有关的问题。
Growth_StuId , --学员id
Growth_Stature , --身高
Growth_Sit , --坐高
Growth_Head , --头围
Growth_Circumference , --胸围
Growth_Avoirdupois , --体重
Growth_Eye , --视力
Re,
max(Growth_Time) --测量时间
from growth
group by
Growth_Id , --
Growth_StuId , --学员id
Growth_Stature , --身高
Growth_Sit , --坐高
Growth_Head , --头围
Growth_Circumference , --胸围
Growth_Avoirdupois , --体重
Growth_Eye , --视力
Re
FROM (SELECT s.*, g.*, row_number() over(PARTITION BY g.Growth_StuId ORDER BY Growth_Time DESC) rn
FROM growth g, student s
WHERE g.Growth_StuId = s.stu_id)
WHERE rn = 1;
from (select Growth_Id,
Growth_StuId, --学员id
Growth_Stature, --身高
Growth_Sit, --坐高
Growth_Head, --头围
Growth_Circumference, --胸围
Growth_Avoirdupois, --体重
Growth_Eye, --视力
Re,
Growth_Time, --测量时间
row_number() over(partition by Growth_StuId order by Growth_Time desc) rn --最新的测量记录为1
from Growth)
where rn = 1
--你学生表应该还有个班级编号字段吧
select b.Growth_StuId,b.Growth_Stature,b.Growth_Sit,b.Growth_Head,
b.Growth_Circumference,b.Growth_Avoirdupois,b.Growth_Eye,b.Growth_Time
from (select a.*,row_number() over(partition by Growth_StuId order by Growth_Time desc ) rn
from 生长发育表 a) b,学生表 c,班级表 d
where b.Growth_StuId=c.stu_id and c.class_id=d.class_id and b.rn=1 and class_name='某一个班级'