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 ...
随机推荐
- 新找到的一款字体 fantasque-sans-mono
http://www.ipreferjim.com/2015/03/your-ides-font-matters-fantasque-sans-mono/
- 《c++程序设计》笔记
本文是学习谭浩强老师的<c++程序设计>后的笔记. 1.概述 c++是贝尔实验室在c语言的基础上发展而来,与c兼容.用c语言写的程序可以不加修改用于c++.从c++的名字可以看出它是c的超 ...
- Replace JSON.NET with Jil JSON serializer in ASP.NET Web API
I have recently come across a comparison of fast JSON serializers in .NET, which shows that Jil JSON ...
- Java 线程间通讯(管道流方式)
一.管道流是JAVA中线程通讯的常用方式之一,基本流程如下: 1)创建管道输出流PipedOutputStream pos和管道输入流PipedInputStream pis 2)将pos和pis匹配 ...
- asp.net 安全性相关参考
<system.web> <depolyment retail="true" /> </system.web> AntiXSS http:/ ...
- [kuangbin带你飞]专题一 简单搜索
ID Origin Title 454 / 1008 Problem A POJ 1321 棋盘问题 328 / 854 Problem B POJ 2251 Dungeon Ma ...
- poj 1258 Agri-Net 最小生成树 kruskal
点击打开链接 Agri-Net Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 33733 Accepted: 13539 ...
- (medium)LeetCode 221.Maximal Square
Given a 2D binary matrix filled with 0's and 1's, find the largest square containing all 1's and ret ...
- JAVA设计模式之调停者模式
在阎宏博士的<JAVA与模式>一书中开头是这样描述调停者(Mediator)模式的: 调停者模式是对象的行为模式.调停者模式包装了一系列对象相互作用的方式,使得这些对象不必相互明显引用.从 ...
- HTML控件-Select
从今天开始,编写对于html控件的特性的探索文章,会广泛的引用网络的资源,所以本文的版权属于广大人民群众,欢迎转载,也同样禁止商业应用. [高手勿喷,标签页点击红色叉叉] select控件有一个特性: ...