今天在運算元據庫時,有乙個新的統計需求id需求:統計2023年一月份列名為a的呼叫量,其中dept_nm和company_name一致的,認為是同一資料,需要去重
company_name
dept_nm
product_nm
op_time
1測試資料1
測試部門1
a2019-02-13 08:12:00
2測試資料1
測試部門1
a2019-01-13 08:12:00
3測試資料3
測試部門3
c2018-01-13 08:12:00
4測試資料4
測試部門4
d2018-08-13 08:12:00
在上述資料中,雖然id 1和2是兩條資料,但是因為是同一部門查詢同一企業,所以認為是一次查詢
select count(*)
from (select company_name,
dept_nm,
product_name,
op_time,
row_number() over(partition by company_name,dept_nm order by company_name,dept_nm) as count
from test)
where count = 1
and product_name='a'
and (op_time between '2019-01-01' and '2019-1-31');
db2修改列型別
alter table salary data alter column salary setdata type decimal 6,2 alter table department addrating char 1 如果修改後出現db2 sql error sqlcode 668時,這個錯誤是表處...
DB2行列轉換
在db2資料庫中常用函式講db2行列轉換 select column1,replace replace xml2clob xmlagg xmlelement name a,column2 as name1 form tablename where 1 0 group by column1 將不需要行...
db2 常量表 DB2檢視使用者表與指定使用者表表結構
1.在dos中檢視使用者表 1.1檢視表 db2 list tables for user 1.2 檢視表結構 db2 describe table a 2.在db2連線工具中 這裡以sqldbx為例子 2.1檢視使用者表清單 select rtrim tabschema as contname,r...