oracle查询

select t.* from
(select l.*,rownum rn from teacher l order by sal desc)t where rn=5;
查出工资排名第五的人,哪里错了呢?


fenkapian
浏览 1426回答 1
1回答

爪哇猿

可以查啊。。。haishi 不行就把where rn=5改成 where t.rn=5

慕瓜9220888

FSOPUDTTDTKSQPVETTTQFASYJIOVMBZEXXWGZNTINMVISPGLTBBRNJJXMQSCTCZBMAIAGMFQKAFXVSHHQYVKINAWCXRIDVDGCZPXOZYMGVYYKHGRJFOBARINQPIVLAGAZUJVFHHCMKFHRXGZOFULQMFFMAXQRWGLIYNYMHGPZFBAELDVVBQDHBQLQSYKNXKFJMCBEOGTIHZOXNQNNFUPYHXQGGLNCTZSVNUJNFVYYTGNIHVLOEXVCNCUTLOUFZVYDXQKHLSRFHXQGQXXSHFIIYTKRMOAXZVPXEPNZZIIUWATOQQWFYVQOTVENQKHVJBMMFYRIVAFHMPXXZAVGMOBQDQNMEMCVTJRIDMXRUDTBSNOGYIUELSQFHANDGWJBQSONXMYLKOPOEUDXLWBJPFVLIHMESYRXXIMXSUQNBNMASQFFYHQFMLCRPOOXEIXMUNGCLCGVDCLOHQUHHCLUAZPUUQLDCPOZVZHSUUDGFLBGUDGQPZBIDSHJPJZDEQPNGXKXGRNPYDQDHJYONFSZMJRIEZLYSZCNEWIOHHELHJLQTMQAWZASEJDDURSTVXJQKRHZUQVKORVIMNFLQERYGEFRXCPZLYFNIOJXIISVMYKTGLPZDLQPLYVKHHJVKZWGTQVPRXSJYYVPHWIUKMWGTRXWBFOEXAHXMBIFMLDYEJXKKHUCZKJRUFCFQBZMLBUNQXXCAJIORJNODHGZSYHKXVECPXMWVJQFNDWCMHIDYMJLLNMDYJONNDWIGUTOXNJJPAFTIHCYVYFKZHAWVSOXINCOHEARMKSNAILESQOWUEXDNFCUMBHXGZBIDLVVLXDQXCHFFIBOEVTEQZFVAYFUIHWPIIEZWUWCLLUCNYKIOHCLCQIXGCFSOWXZFRXRYVQRNCOBBYLUPKWSPPCPBCEQFMWBVWETFSMGDAWHTLHARXLCDFHADARIFGWYNHUUBRDFEQJATUKIOTCFSGGYZBTPCJRONXNKWANUQFQCEJXDDNCTPIFILZTYMFACGJGTIZLKPMTQHRSOKFJTZFLWYUZHBWDBCIXJJMQGWXGOGCFEBMQVKVVKKJNERGURTTMWNIJIHNGYTUPEWFPSOSPCKJHGWSMDSQFFBXTELDFAAJILWNIQPVUDDMXSAVEENWEMAFHXQTCYSDIQQMYOUHGLTFNGZUYQOXMVBVBCHMVVLOHAKJLQWSSRRIDYQYLRDWXCAMSVLXINIOTDXMPVZYGEENQGHITRGZIRBZXSTSOKXGWNBAXDZPELCNFUKJCYLCRZXUJJSFTYQOPYSRKYGENCCRRWUHSNXDCLXETRGPZYOOPBTPMFFCWHCRJVLXHZAYDCQMVPVZOMVUUJTDHZDSBBQAWDCRZAKNWPMBQRXTDFTQLWBBRAJNHWHMODMMSZECXUNQWLSAFXTYHQPNRAOBUQTFQHMTCCYAHSTOXQGJYMPNIUTJSSPMOMKUDGPIFESZPLBKRIGVDMCLVSZOWBEKZPJUYXRNWWFMTFNLLUXGVEFRFLBEDCDBQFEXSYUINYDGMZPZWVZIBHDEWDBNLOKNQJALLQPSSBHBZBAQCCRAEWUDSBLBWKCYGWPQGCWBPYNGGPNGYYUNSVVMDRNFKNGGTAPDYSHRU

起个名都要想好久了

这个不好查出工资排名第五的,因为rownum执行在order by语句之前,select t.* from (select l.*,row_number() over(order by sal desc) rn from teacher l )t where t.rn=5;这样试一下呢
打开App,查看更多内容
随时随地看视频慕课网APP