同時查新多個條件的數量spa
select sum(DECODE(trim(t.ASSESSED_RESULT),'維持',1,0)) maintainNum,
sum(DECODE(trim(t.ASSESSED_RESULT),'晉升',1,0)) upNum,
sum(DECODE(trim(t.ASSESSED_RESULT),'降級',1,0)) degradeNum,
sum(DECODE(trim(t.ASSESSED_RESULT),'終止合同',1,0)) dissolutionNum
from t_AssessResultInfo t, t02salesinfo_backup s
where s.team_id=#{teamId} and t.sales_code=s.sales_code and s.channel_id=#{channelId} and s.year_month=#{month}
and s.year_month=t.stat_month
查詢team_lvl最大的一條數據
select * from (select distinct t.team_id as teamId,t.team_name as orgName,t.team_lvl as teamLvl
from t02salesinfo_backup s,t01teaminfo_backup t
where s.sales_code=#{agentCode} and trim(s.channel_id)=#{channelId} and s.channel_id=t.channel_id
and t.year_month=s.year_month and trim(t.stat)=1 and s.year_month=#{month} and s.sales_id=t.leader_id
order by t.team_lvl desc)where rownum=1
查詢該表中的全部字段名和數據類型 注意:表名必定要大寫!
select A.COLUMN_NAME,A.DATA_TYPE from user_tab_columns A
where TABLE_NAME='T01TEAMINFO'code
多條合併爲一條
原圖:
select sales_code, listagg(index_name, ',')
within group(order by sales_code)indexName from t_SalesWageInfo
group by sales_code;blog
執行後:it