简体   繁体   English

Oracle-SQL-计算多个字段

[英]Oracle - SQL - Count multiple fields

Using Oracle 10G 使用Oracle 10G

Say for example I have a table with three fields in it, I'd like one query which selects the counts of each column where they are not null. 比如说我有一个包含三个字段的表,我想要一个查询,该查询选择不为空的每一列的计数。 Field name 栏位名称

----------------------------------
| strTest1 | strTest2 | strTest3 |
----------------------------------

I know how to get the count of each one individually: 我知道如何分别获取每个人的人数:

select count(*) from tablename where strTest1 is not null

but I'd like to know if it's possible to do this within one query for all 3 fields. 但我想知道是否有可能在所有3个字段的一个查询中执行此操作。

Thanks 谢谢

听起来像您想要的:

SELECT COUNT(STRTEST1), COUNT(STRTEST2), COUNT(STRTEST3) FROM YOUR_TABLE

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM