oracle常用語(yǔ)句

1.decode 函數(shù)(小版本的case when)

成都創(chuàng)新互聯(lián)是一家專(zhuān)注于成都網(wǎng)站設(shè)計(jì)、網(wǎng)站建設(shè)、外貿(mào)網(wǎng)站建設(shè)與策劃設(shè)計(jì),臨洮網(wǎng)站建設(shè)哪家好?成都創(chuàng)新互聯(lián)做網(wǎng)站,專(zhuān)注于網(wǎng)站建設(shè)十年,網(wǎng)設(shè)計(jì)領(lǐng)域的專(zhuān)業(yè)建站公司;建站業(yè)務(wù)涵蓋:臨洮等地區(qū)。臨洮做網(wǎng)站價(jià)格咨詢(xún):028-86922220

select  decode(pd.discount_id,null,'','購(gòu)買(mǎi)'||pd.product_count||'個(gè),'||pd.product_discount_rate||'折優(yōu)惠') as discount 
from b2b_product d right join b2b_product_hot ph on d.product_id = ph.product_id  left join b2b_dictionary a
on d.RRO_MARQUE = a.CODE  left join b2b_dictionaryindex b on d.RRO_BRAND = b.INDEXCODE
left join b2b_company c on d.COMPANY_ID = c.COMPANY_ID
left join b2b_product_discount pd on pd.product_id = d.product_id
order by ph.sort, ph.pro_type;

2.varchar排序

select p.code,
       case
         when p.state = '0' then
          decode(b.state, '1', '1', '0' )
         when p.state = '1' then
          decode(b.state, '0', '0', '1' )
       end as 
  from b2b_paytype_dic p, b2b_buyer_paytype b
where p.code = b.paytype_code(+)
   and (b.buyer_id = ' ' or b.id is null)
   order by to_number(p.code) 

3.case  then 語(yǔ)句

select case when order_state= 2 then '已兌換' when order_state= 3 then '交易成功' end ORDER_STATE , sum(order_count) as cnt from t_report_order t where 1=1 

4.手機(jī)號(hào)的顯示sql 例如 (158****2640)

select  substr(r.mobile,1,3)||'****'||substr(r.mobile,8) as mobile from t_prize_record r;

5.給某個(gè)表備份
select * into xyq_college_20120301(表的別名) from xyq_college(表名)
6.convert 截取時(shí)間
  select *  from vas_mt_viewmt where phone ='15966605352' and convert(nvarchar  (10),createtime,121)='2011-09-14'
7.--將 字符串時(shí)間列,統(tǒng)一轉(zhuǎn)化為時(shí)間,并減一
  update wfjs_useStats_woman
  set createdate=convert(varchar(10),cast(createdate as datetime)-1,120)
8.只復(fù)制表結(jié)構(gòu)的sql
  create table b as select * from a where 1<>1 
9.即復(fù)制表結(jié)構(gòu)又復(fù)制表中數(shù)據(jù)的sql
  create table b as select * from a 
10、將多個(gè)表數(shù)據(jù)插入一個(gè)表中
   insert into 目標(biāo)表test(字段1。。。字段n) (select 字段1.。。。。字段n) from 表 union all select 字段1.....字段n from 表

當(dāng)前名稱(chēng):oracle常用語(yǔ)句
URL標(biāo)題:http://muchs.cn/article0/ihjgio.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供定制網(wǎng)站、搜索引擎優(yōu)化、網(wǎng)站設(shè)計(jì)云服務(wù)器、服務(wù)器托管、網(wǎng)站內(nèi)鏈

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

網(wǎng)站優(yōu)化排名