case..then..oracle函数的研究.......

SELECT a.areaname as 二级地名 FROM houses h,houses h2,
areas a WHERE h.areaid=a.areasid AND h2.areaid=a.areasid AND h.finalassessmentid=1 AND
h.houseslevel=2 AND h2.houseslevel=1 AND a.areasid!=a.parentareasid AND a.companysid=2;

select * from areas
select count(h.houseslevel) as 总数,count(h1.houseslevel) as 最新累计成盘,count(h2.houseslevel) as 最新累计必交盘 from houses h,houses h1,houses h2 where h.houseslevel in (1,2) and h1.houseslevel=1 and h2.houseslevel=2;

select count(h.houseslevel) as 总数 from houses h where h.houseslevel in (1,2)
union all
select count(h.houseslevel) as 成盘 from houses h where h.houseslevel=1
union all
select count(h.houseslevel) as 成盘 from houses h where h.houseslevel=2;

select
count(h.houseslevel) as 总数,
count(case when h.houseslevel=1 then h.housesid end ) 成盘 ,
count(case when h.houseslevel=2 then h.housesid end ) 比较盘
from houses h,areas a where h.areaid=a.areasid and h.houseslevel in (1,2)

SELECT a.areaname AS 二级地名,
count(a.houseId) AS 最新累计有效待售数,
count(h.houseslevel) AS 最新累计必卖盘,count(h2.houseslevel) AS 最新累计成盘 FROM houses h,houses h2,
areas a WHERE h.areaid=a.areasid AND h2.areaid=a.areasid AND h.finalassessmentid=1 AND h.houseslevel=2 AND h2.houseslevel=1 AND a.areasid!=a.parentareasid AND a.companysid=2;

SELECT a.areaname AS 二级地名 FROM houses h,areas a WHERE h.areaid=a.areasid AND a.areasid!=a.parentareasid

SELECT a.areaname AS 二级地名 FROM areas a where a.areaname=

select a.areaname AS 二级地名 from areas a
where a.areaname in (select b.areaname from areas b group by b.areaname having count(b.areaname) > 1)

select b.areaname as 二级地名,count(b.areaname) as 重复数据量 from areas b group by b.areaname having count(b.areaname) > 1

select h.houseslevel from houses h where h.houseslevel=1;

select a.areaname AS 二级地名 from houses h,areas a where h.areaid=h.areaid and h.houseslevel=1 and a.areasid!=a.parentareasid AND a.companysid=2 and h.finalassessmentid=1;

select a.areaname AS 二级地名,
count(h.houseslevel) as 总数,
count(case when h.houseslevel=1 then h.housesid end ) 成盘 ,
count(case when h.houseslevel=2 then h.housesid end ) 比较盘
from houses h,areas a where h.areaid=a.areasid and h.houseslevel in (1,2) and a.areasid!=a.parentareasid AND a.companysid=2 and h.finalassessmentid=1 and flag1=1 group by a.areaname;

时间: 2024-10-09 23:59:57

case..then..oracle函数的研究.......的相关文章

oracle 函数集锦

oracle的函數很多﹐特整理出來﹕ abs(m)  m的绝对值mod(m,n) m被n除后的余数power(m,n) m的n次方round(m[,n]) m四舍五入至小数点后n位的值(n缺省为0)trunc(m[,n]) m截断n位小数位的值(n缺省为0) 字符函数: initcap(st) 返回st将每个单词的首字母大写,所有其他字母小写lower(st) 返回st将每个单词的字母全部小写upper(st) 返回st将每个单词的字母全部大写concat(st1,st2)  返回st为st2接

【函数】Oracle函数系列(1)--字符函数

[函数]Oracle函数系列(1)--字符函数 1  BLOG文档结构图 2  前言部分 2.1  导读和注意事项 各位技术爱好者,看完本文后,你可以掌握如下的技能,也可以学到一些其它你所不知道的知识,~O(∩_∩)O~: ① 常见字符函数(lower.upper.initcap.concat.substr.length.intr.lpad.rpad.trim.chr.ascii.replace.translate)的使用 ② 判断字符串中是否含有汉字 ③ substr和instr的联合使用 ④

ORACLE函数之单行数字函数

 1.           ABS(X) 返回X的绝对值 SQL>SELECT ABS(-1) A,ABS(1) B,ABS(0) C FROM DUAL; A          B          C -------------------- ---------- 1          1          0 2.          ACOS(X) 返回X的反余弦值 SQL>SELECT ACOS(0) A,ACOS(0.5) B,ACOS(1) C FROM DUAL; A    

Oracle——函数

CREATE FUNCTION annual_income(spNAme VARCHAR2) RETURN NUMBER IS yearSal number(7,2);BEGIN  SELECT (sal+NVL(comm,0))*12 INTO yearSal FROM emp WHERE ename=spNAme;  RETURN yearSal;END;/ SQL> var income number;SQL> call annual_income('SMITH') into:incom

Oracle函数+for循环

create or replace function FilterMinganci(str in varchar) return varchar2 is filterWorld varchar2(1000); keyCount int; begin filterWorld := str; keyCount := 0; select count(1) into keyCount from dic_keyword; for aa in (select keyword from dic_keyword

java调用oracle函数

今天写了个oracle函数,但但对java如何调用不是很明白. 今天写了个,并且成功运行了. Connection conn = null; CallableStatement cstmt = null; try { conn = this.getJdbcTemplate().getDataSource().getConnection(); cstmt = conn.prepareCall("{call AUTO_TENDER_NVL(?)}"); cstmt.registerOutP

oracle函数listagg的使用说明(分组后连接字段)

关于oracle函数listagg的使用说明 工作中经常遇到客户提出这样的需求,希望在汇总合并中,能够把日期逐个枚举出来. 如图,原始数据是这样的: 客户希望能够实现这样的汇总合并: 那么通常我会使用listagg这个函数,但是好多网上都是系统的全面的介绍listagg这个函数的使用方法,看起来很费力气.在这里我简明扼要的说明一下 实现这个需求的语句是这样的: select name, listagg(ddate,' / ') within group (order by name) as dd

Oracle函数-高阶篇

下面整理了部分oracle函数-高阶篇: 1. CATSTR    举例:SELECT CATSTR(COLUMN_NAME) NAME_LIST FROM DBA_TAB_COLUMNS WHERE TRIM(TABLE_NAME) = 'T_RZ_DKDATA'  --查询出的结果在一个列中2. INSTR() 检索字符串函数:匹配则返回首次检索的位置的索引值(从1开始),值>0,否则返回值=0    举例:SELECT * FROM USER_TABLES WHERE INSTR(TABL

oracle函数获取汉字拼音的首字母

CREATE OR REPLACE FUNCTION F_TRANS_PINYIN_CAPITAL(P_NAME IN VARCHAR2) RETURN VARCHAR2 AS V_COMPARE VARCHAR2(100); V_RETURN VARCHAR2(4000); FUNCTION F_NLSSORT(P_WORD IN VARCHAR2) RETURN VARCHAR2 AS BEGIN RETURN NLSSORT(P_WORD, 'NLS_SORT=SCHINESE_PINYI