zoukankan      html  css  js  c++  java
  • oracle-记录

    同時查新多个条件的数量

    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'


    多条合并为一条
    原图:

    
    

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

    执行后:



  • 相关阅读:
    初级Linux学习指南
    2016/09/29 SQL中的join
    2016/09/27 Hadoop Yarn
    2016/06/27 HDFS概述
    2016/09/26 电能和电功率
    【转】2016/09/22 MapReduce初级案例
    2016/09/22 mapreduce
    2016/09/21 java关键字static
    2016/09/21 Java关键字final
    2016/09/21 java split用法
  • 原文地址:https://www.cnblogs.com/jjSmileEveryDay/p/9467345.html
Copyright © 2011-2022 走看看