第一次用分析函数,大家指点下

Richard345265669 2009-08-22 01:57:13
select t.*,row_number() over
( partition by t.panel_id, t.eqp_id, t.ppid, t.main_grade, t.glass_grade, t.defect_code_1, t.defect_position_1, t.action_user order by t.time_stamp desc)as rn
from cmv_h_wip_sdef t where rn=1
and t.panel_id='D97005024K75'
;
这个sql没有办法执行,我看的例子都是类似这样的,
t.panel_id, t.eqp_id, t.ppid, t.main_grade, t.glass_grade, t.defect_code_1, t.defect_position_1, t.action_user
这些为表中的主要记录,这些会返回几笔记录,我要取的是时间最后的一笔,谢谢了
...全文
57 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
小灰狼W 2009-08-22
  • 打赏
  • 举报
回复
rn要拉到外面来,因为t表中没有rn这个字段
改成楼上的ok
shiyiwan 2009-08-22
  • 打赏
  • 举报
回复
select * from (
select t.*,
row_number() over( partition by t.panel_id, t.eqp_id, t.ppid, t.main_grade, t.glass_grade, t.defect_code_1, t.defect_position_1, t.action_user order by t.time_stamp desc)as rn
from cmv_h_wip_sdef t where t.panel_id='D97005024K75'
) where rn=1
;

17,088

社区成员

发帖
与我相关
我的任务
社区描述
Oracle开发相关技术讨论
社区管理员
  • 开发
  • Lucifer三思而后行
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧