这个sql该怎么写?关于rownum和order和外查询值做为内查询的参数
update table1 t1
set t1.前复权参数= (select a from
(select tx_temp.aa a
from table1 t2
where t1.dd=t2.dd
order by t2.d)
where rownum =1)
这么写的时候提示t1.dd无效,也就是说在
(select a from
(select tx_temp.aa a
from table1 t2
where t1.dd=t2.dd
order by t2.d)
where rownum =1)
不能识别t1.dd
请各位高手赐教!!!!
问题点数:50、回复次数:7Top
1 楼njhart2003()回复于 2005-08-01 08:48:00 得分 0
只有改一下试试:
update table1 t1
set t1.前复权参数= (select a from
(select tx_temp.aa a
from table1 t2,table1 t1
where t1.dd=t2.dd
order by t2.d)
where rownum =1)
Top
2 楼bobfang(匆匆过客)回复于 2005-08-01 09:04:21 得分 0
楼上njhart2003的语句与原题的需求相差十万八千里哦。^_^Top
3 楼duanzilin(寻)回复于 2005-08-01 09:30:15 得分 0
update table1 t1
set t1.前复权参数= (select a from
(select tx_temp.aa a
from table1 t2
where t1.dd=t2.dd
order by t2.d)
where rownum =1)
这么写的时候提示t1.dd无效,是因为循环嵌套太深,2层以上就不能这么写了
楼上的方法似乎是给每个t1.前复权参数都赋了相同的值,试试下面的方法:
update table1 t1
set t1.前复权参数= (select distinct first_value(tx_temp.aa) over(order by t2.d) a
from table1 t2
where t1.dd=t2.dd
)
Top
4 楼bobfang(匆匆过客)回复于 2005-08-01 12:01:34 得分 0
update table1 t1
set t1.前复权参数= (select min(tx_temp.aa)
from table1 t2,table1 t1
where t1.dd=t2.dd)
这样应该可以吧Top
5 楼duanzilin(寻)回复于 2005-08-01 13:19:39 得分 0
应该是最小的t2.d对应的tx_temp.aa的值,不是最小的tx_temp.aa的值吧Top
6 楼bobfang(匆匆过客)回复于 2005-08-01 14:42:31 得分 0
不好意思,没仔细看Top
7 楼am2004(阿明)回复于 2005-08-01 15:41:28 得分 0
update table1 t1
set t1.前复权参数= (select x.a from t1,
(select tx_temp.aa a
from table1 t2
where t1.dd=t2.dd
order by t2.d) x
where rownum =1)
这样可以吗?
Top




