• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3908
  • Last Modified:

Oracle SQL - Count multiple fields

I need to count the number of records within a table for multiple fields.  I am curretnly using count for each filed.  Is there a way to combine the count function?  

Select count(MARKET) from Table1
Select count(SITE) from Table1
Select count(CYCLE) from Table1
Select count(SYSTYPE) from Table1
0
SharonInGeorgia
Asked:
SharonInGeorgia
2 Solutions
 
MikeOM_DBACommented:

Select count(MARKET) 
     , count(SITE)
     , count(CYCLE)
     , count(SYSTYPE)
  From Table1;

Open in new window

0
 
Naveen KumarProduction Manager / Application Support ManagerCommented:
select count(*) , count(1) from table1 ; -- this will give a count of all the records in the table

select count(market) , count(distinct market ), count(1)
from table1; -- this will give count excluding nulls and count of distinct values excluding nulls and count including nulls

Similary you can do it for other fields. If you need  the counts of the fields in one record output then you have to use as already given above.  If you need in a different format, then let us know and we can try to give you query.

Thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now