Conditional Counting In SQL
|
If you ever want to conditionally count the number of times a particular condition occurs in SQL, you can do it in Oracle using the case andcount functions. Here's a simple example which counts the number of males/females stored in PS_PERSONAL_DATA. select count(case when SEX = 'M' then 1 end) as MALES, count(case when SEX = 'F' then 1 end) asFEMALESfrom PS_PERSONAL_DATA
All that is happening is that the case statement returns a 1 for every instance where the gender is M or F and the count, counts each returned value of 1 giving a summary like this:
The conditions in the case statement can be a lot more complex and can include sub-queries. |
Conditional Counting In SQL的更多相关文章
- pl/sql tutorial
http://plsql-tutorial.com/plsql-procedures.htm What is PL/SQL? PL/SQL stands for Procedural Language ...
- Portswigger web security academy:SQL injection
Portswigger web security academy:SQL injection 目录 Portswigger web security academy:SQL injection SQL ...
- (转载)SQL Reporting Services (Expression Examples)
https://msdn.microsoft.com/en-us/library/ms157328(v=SQL.100).aspx Expressions are used frequently in ...
- 如何知道SQL Server机器上有多少个NUMA节点
如何知道SQL Server机器上有多少个NUMA节点 文章出处: How can you tell how many NUMA nodes your SQL Server has? http://i ...
- EntityFramework 如何查看执行的 SQL 代码?
在 VS 调试的时候,如果我们项目中使用的是 EntityFramework,查看 SQL 执行代码就不像 ADO.NET 那样直观了,我们需要设置下,可以参考下: How can I log the ...
- SQL for SQLite
语法 verb + subject + predicate commannds(命令) SQL由命令组成,以分号为结束.命令有token组成,token由white space分隔,包括空格.tab. ...
- SQLite Learning、SQL Query Optimization In Multiple Rule
catalog . SQLite简介 . Sqlite安装 . SQLite Programing . SQLite statements 1. SQLite简介 SQLite是一款轻型的数据库,是遵 ...
- MONGODB 与sql聚合操作对应图
MongoDB 高级查询条件操作符 2012-04-25 15:35:19| 分类: MongoDB | 标签:mongodb使用 mongodb查询 |举报|字号 订阅 http://blo ...
- P6 Professional Installation and Configuration Guide (Microsoft SQL Server Database) 16 R1
P6 Professional Installation and Configuration Guide (Microsoft SQL Server Database) 16 R1 May ...
随机推荐
- Go Mobile 例子 basic 源码分析
OpenGL ES(OpenGL for Embedded Systems)是 OpenGL 三维图形API的子集,针对手机.PDA和游戏主机等嵌入式设备而设计.该API由Khronos集团定义推广, ...
- Ext TreeGrid提交修改过的数据
本打算将整个treestore的数据提交到服务器,但找来找去没有找到好的方法,在翻api的时候发现了getUpdatedRecords()方法,拿来一试,试出此方法可以拿到被修改过的record so ...
- [ZOJ 3839] Poker Face (递归)
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3839 题目大意:画脸..每张脸是上一个脸倒过来加上眼睛.. 注意 ...
- [HDU 4821] String (字符串哈希)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4821 题目大意:给你M,L两个字母,问你给定字串里不含M个长度为L的两两相同的子串有多少个? 哈希+枚 ...
- java爬虫实战
1.下载jxl.jar包,网上多的是 2.编写如下代码: package com.beyond.url; import java.io.BufferedReader;import java.io.Fi ...
- selenium简介
Selenium是一个开源的和便携式的自动化软件测试工具,用于测试Web应用程序有能力在不同的浏览器和操作系统运行.Selenium真的不是一个单一的工具,而是一套工具,帮助测试者更有效地基于Web的 ...
- Web前端面试常识
大四校招即将席卷而来,现在临时抱抱佛脚,百度一下大概可能会问到的知识点,愿与君共勉吧! 1.Doctype(html4) A.strict 严格版本 B.transitional 过渡版本(防止 ...
- Maven本地资源库
在本地安装的mvn文件夹中找到conf/setting.xml,然后找到localRepository结点,这个路径值就是Maven的实际路径 打开该文件夹就能够看到
- PMP考试--价值工程法
如果你对项目管理.系统架构有兴趣,请加微信订阅号"softjg",加入这个PM.架构师的大家庭 ValueEngineering,简称VE,是降低成本提高经济效益的有效方法,价值工 ...
- USACO Section 2.4 回家 Bessie Come Home
题目描述 现在是晚餐时间,而母牛们在外面分散的牧场中. 农民约翰按响了电铃,所以她们开始向谷仓走去. 你的工作是要指出哪只母牛会最先到达谷仓(在给出的测试数据中,总会有且只有一只最快的母牛). 在挤奶 ...