对Oracle函数的整理 count substr

1、count(*) 表示 将所有的数据查出来(包括空值)

substr(xzqdm,1,6)表示 对xzqdm进行截取,数字表示从第一位到第六位,substr(xzqdm,0,6)效果一样


详述请看

http://blog.csdn.net/djfkd/article/details/3300152



2、列传行

select t.jgdm ,
       decode(s.xzqmc, '厦门市', t.yw_guid) 厦门市,
       decode(s.xzqmc, '集美区', t.yw_guid) 集美区
  from dc_ydqkdcb t, public_xzqh s
  where t.jgdm = s.xzqdm


select 厦门市 + 思明区 + 湖里区 + 海沧区 + 集美区 +同安区+翔安区 as 总计 ,厦门市,思明区 ,湖里区,海沧区,集美区,同安区,翔安区 from (select 
       count(decode(s.xzqmc, '厦门市', t.yw_guid)) 厦门市,
       count(decode(s.xzqmc, '思明区', t.yw_guid)) 思明区,
       count(decode(s.xzqmc, '湖里区', t.yw_guid)) 湖里区,
       count(decode(s.xzqmc, '海沧区', t.yw_guid)) 海沧区,
       count(decode(s.xzqmc, '集美区', t.yw_guid)) 集美区,
       count(decode(s.xzqmc, '同安区', t.yw_guid)) 同安区,
       count(decode(s.xzqmc, '翔安区', t.yw_guid)) 翔安区
  from dc_ydqkdcb t, public_xzqh s
  where t.jgdm = s.xzqdm ) 


3、Oracle error:不是group by 表达式

解决办法:聚组函数以外的所有字段都要出现在group by后面.


你可能感兴趣的:(Oracle)