金融保險 » Rambler Channel 登入 註冊 推介網誌 行業分類 人氣榜 最新記事

« 上一頁 | 下一頁 »

SQL - DB2 Temporary Tables - WITH Statement

 with
      temp1 as (select pub_name, max(c_price) as maxprice
                           from book group by pub_name),
      temp2 as (select  pub_name,  maxprice from temp1
                    where maxprice = (select max(maxprice) from temp1) )
      select case when t.maxprice = t2.maxprice  then '*' else '' END,
        k.pub_name, isbn, author, title, c_price
        from book k, temp1 t , temp2 t2
        where k.pub_name = t.pub_name and
              k.c_price = t.maxprice
        order by k.pub_name;

 source: http://www.cs.newpaltz.edu/~pletcha/DB/db2_TempTables.html

發表回應

(您尚未登入,您可匿名回應。或選擇按此登入註冊)

 暱稱 (必填)

 標題

 個人網頁

 電子郵件

authimage 
 驗證碼 (必填)