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

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

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

    海上月明

    editer by sun
    posts - 162, comments - 51, trackbacks - 0, articles - 8
       :: 首頁 :: 新隨筆 ::  :: 聚合  :: 管理

    oracle多列子查詢的實現[轉]

    Posted on 2010-12-15 13:22 pts 閱讀(407) 評論(0)  編輯  收藏

    From:http://database.51cto.com/art/201010/231773.htm

    oracle多列子查詢是oracle數據庫中的一種查詢方式,下面就為您詳細介紹oracle多列子查詢的實現方法,希望能夠對您能夠有所幫助。

    多列子查詢:

    oracle子查詢一般都是返回單列,實際上數據庫對此并沒有進行限制,子查詢也可以返回多列.oracle多列子查詢的例子:
    檢索每種產品在其類型中價格最低的產品:
    步驟:

    1.通過分組查詢,統計每類產品的最低價格:

    <ol class="dp-xml" style="margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 1px !important; margin-left: 3em !important; padding-top: 5px; padding-right: 0px; padding-bottom: 5px; padding-left: 20px; list-style-type: decimal; list-style-position: initial; list-style-image: initial; background-image: url(http://www.51cto.com/images/art/images/010101bg.gif); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; color: #000000; line-height: 30px; background-position: initial initial; background-repeat: no-repeat repeat; border: 0px none initial;"><li class="alt" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 12px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 14px; list-style-type: decimal; list-style-position: outside !important; list-style-image: initial; color: inherit; line-height: 24px; background-image: url(http://www.51cto.com/images/art/AppData/Roaming/Adobe/Dreamweaver%20CS4/zh_CN/Configuration/images/dt1.gif); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: no-repeat no-repeat; border: 0px none initial;"><span style="color: black; background-color: inherit; padding: 0px; margin: 0px; border: 0px none initial;"><span style="color: black; background-color: inherit; padding: 0px; margin: 0px; border: 0px none initial;">select product_type_id,min(Price) from products group by product_type_id </span></span></li></ol>


    結果為:

    PRODUCT_TYPE_ID MIN(PRICE)
    --------------- ----------
                  1                       19.95
                  2                       13.95
                  3                       12.99
                  4                       10.99
                                           13.49

    2. 然后再掃描產品表中每行數據,看當前行的類別編輯與價格是否屬于上面子查詢中的一項;
    完整查詢:

    <ol class="dp-xml" style="margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 1px !important; margin-left: 3em !important; padding-top: 5px; padding-right: 0px; padding-bottom: 5px; padding-left: 20px; list-style-type: decimal; list-style-position: initial; list-style-image: initial; background-image: url(http://www.51cto.com/images/art/images/010101bg.gif); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; color: #000000; line-height: 30px; background-position: initial initial; background-repeat: no-repeat repeat; border: 0px none initial;"><li class="alt" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 12px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 14px; list-style-type: decimal; list-style-position: outside !important; list-style-image: initial; color: inherit; line-height: 24px; background-image: url(http://www.51cto.com/images/art/AppData/Roaming/Adobe/Dreamweaver%20CS4/zh_CN/Configuration/images/dt1.gif); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: no-repeat no-repeat; border: 0px none initial;"><span style="color: black; background-color: inherit; padding: 0px; margin: 0px; border: 0px none initial;"><span style="color: black; background-color: inherit; padding: 0px; margin: 0px; border: 0px none initial;">select product_id,product_type_id,name,price  </span></span></li><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 12px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 14px; list-style-type: decimal; list-style-position: outside !important; list-style-image: initial; color: #000000; line-height: 24px; background-image: url(http://www.51cto.com/images/art/AppData/Roaming/Adobe/Dreamweaver%20CS4/zh_CN/Configuration/images/dt1.gif); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: no-repeat no-repeat; border: 0px none initial;"><span style="color: black; background-color: inherit; padding: 0px; margin: 0px; border: 0px none initial;">from products  </span></li><li class="alt" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 12px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 14px; list-style-type: decimal; list-style-position: outside !important; list-style-image: initial; color: inherit; line-height: 24px; background-image: url(http://www.51cto.com/images/art/AppData/Roaming/Adobe/Dreamweaver%20CS4/zh_CN/Configuration/images/dt1.gif); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: no-repeat no-repeat; border: 0px none initial;"><span style="color: black; background-color: inherit; padding: 0px; margin: 0px; border: 0px none initial;">where  </span></li><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 12px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 14px; list-style-type: decimal; list-style-position: outside !important; list-style-image: initial; color: #000000; line-height: 24px; background-image: url(http://www.51cto.com/images/art/AppData/Roaming/Adobe/Dreamweaver%20CS4/zh_CN/Configuration/images/dt1.gif); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: no-repeat no-repeat; border: 0px none initial;"><span style="color: black; background-color: inherit; padding: 0px; margin: 0px; border: 0px none initial;">(product_type_id , price)  </span></li><li class="alt" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 12px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 14px; list-style-type: decimal; list-style-position: outside !important; list-style-image: initial; color: inherit; line-height: 24px; background-image: url(http://www.51cto.com/images/art/AppData/Roaming/Adobe/Dreamweaver%20CS4/zh_CN/Configuration/images/dt1.gif); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: no-repeat no-repeat; border: 0px none initial;"><span style="color: black; background-color: inherit; padding: 0px; margin: 0px; border: 0px none initial;">in  </span></li><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 12px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 14px; list-style-type: decimal; list-style-position: outside !important; list-style-image: initial; color: #000000; line-height: 24px; background-image: url(http://www.51cto.com/images/art/AppData/Roaming/Adobe/Dreamweaver%20CS4/zh_CN/Configuration/images/dt1.gif); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: no-repeat no-repeat; border: 0px none initial;"><span style="color: black; background-color: inherit; padding: 0px; margin: 0px; border: 0px none initial;">(select product_type_id , min(price)  </span></li><li class="alt" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 12px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 14px; list-style-type: decimal; list-style-position: outside !important; list-style-image: initial; color: inherit; line-height: 24px; background-image: url(http://www.51cto.com/images/art/AppData/Roaming/Adobe/Dreamweaver%20CS4/zh_CN/Configuration/images/dt1.gif); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: no-repeat no-repeat; border: 0px none initial;"><span style="color: black; background-color: inherit; padding: 0px; margin: 0px; border: 0px none initial;">from   </span></li><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 12px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 14px; list-style-type: decimal; list-style-position: outside !important; list-style-image: initial; color: #000000; line-height: 24px; background-image: url(http://www.51cto.com/images/art/AppData/Roaming/Adobe/Dreamweaver%20CS4/zh_CN/Configuration/images/dt1.gif); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: no-repeat no-repeat; border: 0px none initial;"><span style="color: black; background-color: inherit; padding: 0px; margin: 0px; border: 0px none initial;">products  </span></li><li class="alt" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 12px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 14px; list-style-type: decimal; list-style-position: outside !important; list-style-image: initial; color: inherit; line-height: 24px; background-image: url(http://www.51cto.com/images/art/AppData/Roaming/Adobe/Dreamweaver%20CS4/zh_CN/Configuration/images/dt1.gif); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: no-repeat no-repeat; border: 0px none initial;"><span style="color: black; background-color: inherit; padding: 0px; margin: 0px; border: 0px none initial;">group by   </span></li><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 12px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 14px; list-style-type: decimal; list-style-position: outside !important; list-style-image: initial; color: #000000; line-height: 24px; background-image: url(http://www.51cto.com/images/art/AppData/Roaming/Adobe/Dreamweaver%20CS4/zh_CN/Configuration/images/dt1.gif); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: no-repeat no-repeat; border: 0px none initial;"><span style="color: black; background-color: inherit; padding: 0px; margin: 0px; border: 0px none initial;">product_type_id) </span></li></ol>

    查詢結果:
    PRODUCT_ID PRODUCT_TYPE_ID NAME                                PRICE
    ---------- --------------- ------------------------------ ----------
             1               1 Modern Science                                               19.95
             4               2 Tank War                                                         13.95
             8               3 From Another Planet                                        12.99
             9               4 Classical Music                                                 10.99 


    只有注冊用戶登錄后才能發表評論。


    網站導航:
     
    主站蜘蛛池模板: 最近免费字幕中文大全视频 | 成在线人免费无码高潮喷水| 亚洲国产av一区二区三区丶| 亚洲午夜福利717| 亚洲gv猛男gv无码男同短文| 亚洲网站免费观看| 国产成人亚洲综合a∨| 二区久久国产乱子伦免费精品| 99久久免费国产特黄| 97在线观看永久免费视频| 日韩高清在线免费看| 夜夜春亚洲嫩草影院| 亚洲18在线天美| 一区二区在线免费视频| 18禁无遮挡无码国产免费网站| 99爱在线观看免费完整版| 国产猛烈高潮尖叫视频免费| 无码乱人伦一区二区亚洲一| 久久无码av亚洲精品色午夜| 国产又黄又爽又大的免费视频| 毛片基地免费视频a| 亚洲精品乱码久久久久66| 久久人午夜亚洲精品无码区| 亚洲国产成人a精品不卡在线| 四虎永久成人免费| 亚洲字幕在线观看| 亚洲免费观看视频| 亚洲AV成人精品日韩一区18p| 日本特黄特黄刺激大片免费| 高潮毛片无遮挡高清免费视频| 免费无毒a网站在线观看| 在线精品免费视频无码的| 久久久久亚洲精品日久生情| 国产日韩AV免费无码一区二区三区| 日日躁狠狠躁狠狠爱免费视频| 国产97视频人人做人人爱免费| 成人精品视频99在线观看免费| 免费观看的a级毛片的网站| 亚洲精品**中文毛片| 国产色爽免费视频| 色欲色香天天天综合网站免费|