oracle sql问题
现在要做一个查询,查询所有用户中weight的和中最大的用户的custname 本人新手 跪求高人指点,可能要做聚集函数嵌套之类的 只是语法是在不是很熟悉
custom表 custid custname shipstuff表 custid weight 中
a001 d1 a001 500
a002 d2 a003 300
a003 d3 a001 400
a002 400
a003 200
追问:能给出每条语句的详细解释不 谢谢了能给出每条语句的详细解释不 谢谢了
答案:select *
from custom
where custid = (
select custid
from (select custid, sum(weight) as val
from shipstuff group by custid)
where rowunm=1
order by val desc
)
其他:select custname from custom
where custid = (select custid
from (select custid, sum(weight) wt from shipstuff
group by custid
order by val desc)
where rownum=1
) 这样的表结构 没法看啊
上一个:帮我写一个oracle的存储过程吧,
下一个:oracle 如何调用 sybase 的数据