<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    數(shù)據(jù)加載中……
    oracle中rownum的用法
           最近在做一個(gè)項(xiàng)目,因?yàn)榭紤]的主要是實(shí)現(xiàn)查詢,所以沒(méi)有用到Hibernate。直接用的jdbc,里面涉及到分頁(yè),所以用到rownum了。
         比如,寫(xiě)個(gè)最簡(jiǎn)單的用法:select *from (select *from adjustrequsition a order by a.applydate desc) where rownum<6;這樣才是正確的想法,往往像我這樣的新手,喜歡這樣寫(xiě):select *from adjustrequsition a where rownum<6 order by a.applydate desc; 這樣是最容易范的錯(cuò)誤。。因?yàn)閞ownum是先從數(shù)據(jù)庫(kù)中任意取的數(shù)據(jù),然后在按條件排序。。HOHO。。
         下面是我寫(xiě)的我工作4個(gè)月來(lái)最長(zhǎng)的sql代碼,畢竟我不是DBA哦。。呵呵
        

    select *
     from (select row_number() over(order by t.BEGIN_DATE) ranging,
                   decode(action_seq,
                         
    2,
                          t.person_name,
                         
    3,
                          (select name from account where id = s1.main_account_seq),
                          (select name from account where id = s1.main_account_seq)) as debit_name,
                   decode(action_seq,
                         
    7,
                          t.person_name,
                         
    4,
                          (select name from account where id = s1.main_account_seq),
                          (select name from account where id = s2.main_account_seq)) as credit_name,
                   (SELECT action_name FROM action_type WHERE t.action_seq = ID) AS action_name,
                   decode(action_seq,
                         
    2,
                          decode(bank_seq,
                                 null,
                                
    '郵局',
                                 (select bank_name
                                    from bank_info
                                   where id = t.bank_seq)),
                          (select bank_name from bank_info where id = t.bank_seq)) bankname,
                   decode(action_seq,
                         
    2,
                          t.card_no,
                          (select decode(a.email, null, a.mobile, a.email)
                             from account a, sub_account s
                            where a.id = s.main_account_seq
                              and s.id = t.debit_seq)) as debit_no,
                   decode(action_seq,
                         
    4,
                          t.card_no,
                         
    7,
                          t.card_no,
                          (select decode(a.email, null, a.mobile, a.email)
                             from account a, sub_account s
                            where a.id = s.main_account_seq
                              and s.id = t.credit_seq)) as credit_no,
                   t.amount,
                   to_char(t.BEGIN_DATE,
    'YYYY-MM-DD hh24:mi') as begin_date,
                   t.remark,
                   t.id,
                   t.voucher_code,
                   t.DEBIT_FEE,
                   t.CREDIT_FEE
              from transaction t, sub_account s1, sub_account s2
             where t.voucher_code is not null
            
               and exists
             (select s.id
                      from account a, sub_account s
                     where s.main_account_seq = a.id
                       and a.account_type =
    'B'
                       and (t.credit_seq = s.id or t.debit_seq = s.id))
               and t.DEBIT_SEQ = s1.ID
               and t.CREDIT_SEQ = s2.ID
               and t.action_seq =
    3)
     where ranging between
    1 and 100

    posted on 2007-08-17 16:08 flyleer 閱讀(355) 評(píng)論(0)  編輯  收藏


    只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


    網(wǎng)站導(dǎo)航:
     
    主站蜘蛛池模板: 性无码免费一区二区三区在线| 国产亚洲漂亮白嫩美女在线 | 免费**毛片在线播放直播| 91大神亚洲影视在线| 亚洲一区二区女搞男| xxxxxx日本处大片免费看| 内射无码专区久久亚洲| 日韩在线观看免费| 国产gv天堂亚洲国产gv刚刚碰| 日韩久久无码免费毛片软件| 亚洲黄色免费网站| 亚洲国产日韩在线| 91成人免费福利网站在线| 国产精品免费综合一区视频| 亚洲精品精华液一区二区 | 1000部夫妻午夜免费| 亚洲一卡2卡3卡4卡国产网站| 99久久这里只精品国产免费| 亚洲精品天堂无码中文字幕| 免费jlzzjlzz在线播放视频| 成人免费网站视频www| 亚洲欧洲日产国码av系列天堂 | 国产无遮挡色视频免费观看性色| 永久免费的网站在线观看| 亚洲熟妇无码一区二区三区| 免费**毛片在线播放直播| 中文字幕不卡高清免费| 亚洲精品自拍视频| 精品免费国产一区二区三区 | 亚洲va中文字幕无码| 成人爽a毛片免费| 亚洲一级毛片视频| 亚洲av午夜精品一区二区三区| 最近2019中文免费字幕在线观看| 亚洲大香人伊一本线| 俄罗斯极品美女毛片免费播放| 色播在线永久免费视频网站| 亚洲天堂免费在线| 亚洲三区在线观看无套内射| 一个人看的www在线观看免费| 男人j进女人p免费视频|