Solved

Oracle SQL - Count multiple fields

Posted on 2008-06-13
4
3,887 Views
Last Modified: 2013-12-07
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
Comment
Question by:SharonInGeorgia
4 Comments
 
LVL 29

Accepted Solution

by:
MikeOM_DBA earned 63 total points
ID: 21781401

Select count(MARKET) 

     , count(SITE)

     , count(CYCLE)

     , count(SYSTYPE)

  From Table1;

Open in new window

0
 
LVL 28

Assisted Solution

by:Naveen Kumar
Naveen Kumar earned 62 total points
ID: 21790802
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

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Subquery in Oracle: Sub queries are one of advance queries in oracle. Types of advance queries: •      Sub Queries •      Hierarchical Queries •      Set Operators Sub queries are know as the query called from another query or another subquery. It can …
Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
This video shows how to recover a database from a user managed backup

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now