惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

N
News | PayPal Newsroom
Security Archives - TechRepublic
Security Archives - TechRepublic
Hacker News: Ask HN
Hacker News: Ask HN
H
Hacker News: Front Page
Apple Machine Learning Research
Apple Machine Learning Research
TaoSecurity Blog
TaoSecurity Blog
Help Net Security
Help Net Security
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
V
V2EX
Hugging Face - Blog
Hugging Face - Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
人人都是产品经理
人人都是产品经理
博客园 - 三生石上(FineUI控件)
Security Latest
Security Latest
Cloudbric
Cloudbric
WordPress大学
WordPress大学
S
SegmentFault 最新的问题
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Know Your Adversary
Know Your Adversary
A
Arctic Wolf
L
LangChain Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
The GitHub Blog
The GitHub Blog
P
Proofpoint News Feed
W
WeLiveSecurity
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
M
MIT News - Artificial intelligence
Google DeepMind News
Google DeepMind News
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
The Cloudflare Blog
小众软件
小众软件
NISL@THU
NISL@THU
云风的 BLOG
云风的 BLOG
P
Privacy & Cybersecurity Law Blog
S
Security @ Cisco Blogs
博客园 - 【当耐特】
I
InfoQ
Vercel News
Vercel News
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
P
Proofpoint News Feed
O
OpenAI News
Google DeepMind News
Google DeepMind News
N
News and Events Feed by Topic
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
K
Kaspersky official blog
T
Threat Research - Cisco Blogs
量子位
宝玉的分享
宝玉的分享

博客园 - 山娃

Oracle ORA-01722: 无效数字 处理方法 PB程序系统错误处理记录 网上摘录(琐碎信息) 网上摘录 Oracle 要点摘录 存储过程中如何使用另一个存储过程返回的结果集 网络转帖 如何用Powerdesigner的PDM(物理数据模型)生成数据库及逆向工程(将现有的数据库生成PDM)(转) Oracle中返回结果集的存储过程(转帖 网摘) Oracle to_timestamp 函数测试(摘录,转帖) Oracle 查询历史数据(转帖) Oracle REF Cursor 用法(转帖) Oracle PL/SQL中如何使用%TYPE和%ROWTYPE(转帖) Oracle中的Instance实例和数据库的区别 . 转帖 建立与Oracle数据库服务器连接的两种连接模式(专用服务器与共享服务器) .转帖 Oracle10g数据库的4种存储形式 .转帖 PB “Row changed between retrieve and update” 经典错误处理。 转帖 PLSQLDEV 中修改主表和子表的主键,外键信息 oracle查询表信息(索引,外键,列等。。) 转帖 人生规划(网摘)
网上摘录 数据分组处理
山娃 · 2013-02-05 · via 博客园 - 山娃

当数据重复的时候分组才有意义。

注意点:WHERE和HAVING的区别

  • WHERE:是在执行GROUP BY操作之前进行的过滤,表示从全部数据之中筛选出部分的数据,在WHERE之中不能使用统计函数;
  • HAVING:是在GROUP BY分组之后的再次过滤,可以在HAVING子句中使用统计函数;

示例:

select
    b.dept_code dept_id,
   decode(a.find_emp_code,'','小计:',a.find_emp_code) maker,
   count(a.request_id) list_num,
 (count(a.request_id)*to_number((select INFO_DETAIL_VALUE1 from equ_sys_info_detail where info_type_code = '075' and INFO_DETAIL_CODE='01'))) list_sum,
 to_number(null)     bath_num,
 (to_number(null)*to_number((select INFO_DETAIL_VALUE1 from equ_sys_info_detail where info_type_code = '075' and INFO_DETAIL_CODE='02'))) bath_sum
  
 from  EQU_MAINTAIN_REQUEST_ORDER a ,PER_INFO b
   where a.find_emp_code = b.emp_code and a.state_id not in(01,23,24,99) and b.dept_code <>'010301' and b.dept_code like '0103%' 
   group by b.dept_code,rollup(a.find_emp_code)

--查询结果  每个部门自动显示小计数据

 1 010302 3013 212 2120  
2 010302 3016 75 750  
3 010302 3017 37 370  
4 010302 3023 74 740  
5 010302 3024 115 1150  
6 010302 3043 82 820  
7 010302 3048 53 530  
8 010302 3107 18 180  
9 010302 3109 5 50  
10 010302 小计: 671 6710  
11 010303 3019 33 330  
12 010303 3020 47 470  
13 010303 3027 39 390  
14 010303 3029 52 520  
15 010303 3030 36 360  
16 010303 3044 119 1190  
17 010303 3046 68 680  
18 010303 3077 16 160  
19 010303 3092 4 40  
20 010303 3106 10 100  
21 010303 小计: 424 4240  
22 010304 3018 25 250  
23 010304 3022 219 2190  
24 010304 3031 38 380  
25 010304 3032 58 580  
26 010304 3039 69 690  
27 010304 3053 29 290  
28 010304 3081 38 380  
29 010304 3087 48 480  
30 010304 3105 19 190  
31 010304 3108 8 80  
32 010304 小计: 551 5510  
33 010305 3014 70 700  
34 010305 3035 27 270  
35 010305 3036 66 660  
36 010305 3038 10 100  
37 010305 3042 35 350  
38 010305 3047 52 520  
39 010305 3051 11 110  
40 010305 3054 166 1660  
41 010305 3076 42 420  
42 010305 3078 24 240  
43 010305 小计: 503 5030  
44 010306 3004 5 50  
45 010306 3008 30 300  
46 010306 3009 10 100  
47 010306 3055 4 40  
48 010306 小计: 49 490  
49 010308 3011 111 1110  
50 010308 3026 80 800  
51 010308 3034 44 440  
52 010308 3041 117 1170  
53 010308 3045 325 3250  
54 010308 3050 103 1030  
55 010308 3052 47 470  
56 010308 3079 71 710  
57 010308 3086 53 530  
58 010308 3097 4 40  
59 010308 小计: 955 9550