当前位置: 代码迷 >> Oracle开发 >> 请大侠帮小弟我参考下这种需求的语句如何写
  详细解决方案

请大侠帮小弟我参考下这种需求的语句如何写

热度:113   发布时间:2016-04-24 06:37:13.0
请大侠帮我参考下这种需求的语句怎么写?
有两张表
A(id), 
B(aid,id,instance,quantity)

 要求是A表和B表做联表查询,如果A对应的所有记录的quantity的合大于40
 就标记 字段instance值为 important

初学,后面的那个子查询写不出来。。。
------解决方案--------------------

update b
set instance = 'important'
where id in (
  select b.id from a, b
   where a.id = b.id
   group by b.id
   having sum(quantity) > 40
)
  相关解决方案