同時查新多个条件的数量

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'

多条合并为一条
原图:

oracle-记录-LMLPHP

select sales_code, listagg(index_name, ',')
within group(order by sales_code)indexName from t_SalesWageInfo
group by sales_code;

执行后:

oracle-记录-LMLPHP

05-28 21:16