1. 程式人生 > >Oracle 關鍵字、高級函數的使用

Oracle 關鍵字、高級函數的使用

info pre ntc rowid ant pan inf sum 一個

1.序列、唯一標識

  查詢時,可以添加遞增序列 rownum

  表的數據每一行都有一個唯一的標識 rowid

  技術分享圖片

2.函數

  單行:查詢多條數據

    如:to_date()

  多行:查詢總結數據,一般用於group by

    如:sum()

3.去重 distinct

  select distinct  from tablename

4.分區 partition

  select tenantcode,row_number() over(partition by tenantcode order by tenantcode, brandcode, storecode ) groupid
  
from tablename

    技術分享圖片

  若要分區篩選出id=1的,可以

select * from(
select tenantcode,row_number() over(partition by tenantcode order by tenantcode, brandcode, storecode) groupid
from tablename
)
where groupid=1

Oracle 關鍵字、高級函數的使用