update fee set feetype=91003 where sourcefilename in (select * from (select sourcefilename from songlist where videotype in ('hjych','zxych') order bysourcefilename) where rownum<=3);update fee set feetype=91002 where sourcefilename in (select * from (select sourcefilename from songlist where videotype in ('hjych','zxych') order bysourcefilename) where rownum<=2);update fee set feetype=91001 where sourcefilename in (select * from (select sourcefilename from songlist where videotype in ('hjych','zxych') order bysourcefilename) where rownum<=1);想問一下,這語句是做什么用的
2 回答

30秒到達戰場
TA貢獻1828條經驗 獲得超6個贊
這三條sql語句的作用應該是 更新一個歌曲排行榜的前1、2、3名吧。
至于zxy和hjy不知道是什么,后面的ch應該是中文的意思吧。
想要用rownum取查詢結果的前幾名,
一般情況(如果需要以某個字段排序的話)必須嵌套select

ITMISS
TA貢獻1871條經驗 獲得超8個贊
對于rownum來說它是oracle系統順序分配為從查詢返回的行的編號,返回的第一行分配的是1,第二行是2,依此類推
rownum 對于等于某值的查詢條件
如果希望找到學生表中第一條學生的信息,可以使用rownum=1作為條件。但是想找到學生表中第二條學生的信息,使用rownum=n(n》1)結果查不到數據
rownum》1原因是由于rownum是一個總是從1開始,結果查不到數據
rownum對于小于某值的查詢條件
如果想找到第n條記錄以前的記錄,當使用rownum<n是能得到n-1條記錄的
- 2 回答
- 0 關注
- 438 瀏覽
添加回答
舉報
0/150
提交
取消