同一种物料价格随着时间波动,如何写sql来取最近时间的价格?

新:

FineReport 帆软用户WvxHgnD4Y1 发布于 2023-12-15 14:06 (编辑于 2023-12-17 14:38)
1min目标场景问卷 立即参与
回答问题
悬赏:3 F币 + 添加悬赏
提示:增加悬赏、完善问题、追问等操作,可使您的问题被置顶,并向所有关注者发送通知
共4回答
最佳回答
0
用户k6280494Lv6资深互助
发布于2023-12-15 14:07

select jg from a where rq=(select max(rq) from a)

最佳回答
0
snrtuemcLv8专家互助
发布于2023-12-15 14:08

select max(price) as price,wlmc,wldj from 表 gruop by wlmc,wldj

最佳回答
0
Z4u3z1Lv6专家互助
发布于2023-12-15 14:09

SqlServer为例

select * from 

(select row_number() over(partition by name order by zh desc) [i],* from tablename) A WHERE A.I=1

image.png

最佳回答
0
华莉星宸Lv7高级互助
发布于2023-12-15 14:16(编辑于 2023-12-15 14:17)

Oracle写法参考如下:

select *

  from 表 a

 where a.物料 || a.时间 in

       (select 物料 || 时间

          from (select 物料, max(时间) as 时间 from 表 group by 物料))

  • 3关注人数
  • 255浏览人数
  • 最后回答于:2023-12-17 14:38
    请选择关闭问题的原因
    确定 取消
    返回顶部