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 ...
随机推荐
- [Java] 匿名内部类
package test.file; import java.io.File; import java.io.FilenameFilter; /** * 匿名的内部类 * @author Frost. ...
- 为什么wait(),notify()和notifyAll()必须在同步块或同步方法中调
我们常用wait(),notify()和notifyAll()方法来进行线程间通信.线程检查一个条件后就行进入等待状态,例如,在"生产者-消费者"模型中,生产者线程发现缓冲区满了就 ...
- eclipse快捷键使用
Eclipse的编辑功能非常强大,掌握了Eclipse快捷键功能,能够大大提高开发效率.Eclipse中有如下一些和编辑相关的快捷键.1. [ALT+/]此快捷键为用户编辑的好帮手,能为用户提供内容的 ...
- 批量修改java文件的包名
需求:我复制进批量的java文件,但是包名需要用现在创建的包名 导入进来时,由于包名不一致会报错 解决办法,点击包名鼠标右键>Refactor>Rename 结果如下ok:
- Java中Map的用法
Map的一般用法 1.声明一个Map : Map map = new HashMap(); 2 .向map中放值 ,注意: map是key-value的形式存放的,如: map.put("s ...
- esriSRGeoCSType Constants
ArcGIS Developer Help (Geometry) esriSRGeoCSType Constants See Also esriSRGeoCS2Type Constants ...
- 零成本实现接口自动化测试 – Java+TestNG 测试Restful service
接口自动化测试 – Java+TestNG 测试 Restful Web Service 关键词:基于Rest的Web服务,接口自动化测试,数据驱动测试,测试Restful Web Service, ...
- Django网站直接使用supervisor部署
python manage.py createsuperuser python manage.py migrate 生成网站的supervisor配置文件: echo_supervisord_conf ...
- 共享池之六:shared pool latch/ library cache latch /lock pin 简介
latch:library cache --desc v$librarycache; latch:library cache用于保护hash bucket.library cache lock保护HA ...
- java解析xml的4种经典方法
========================================== xml文件 <?xml version="1.0" encoding="GB2 ...