Solved

Oracle SQL - Count multiple fields

Posted on 2008-06-13
4
3,892 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
grant user/role question 11 36
migration MS SQL database to Oracle 30 71
oracle differnce between two timestamps 5 39
Need help on decision table structure 7 46
How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
Shell script to create broker configuration file using current broker Configuration, solely for purpose of backup on Linux. Script may need to be modified depending on OS-installation. Please deploy and verify the script in a test environment.
This video shows how to recover a database from a user managed backup
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.

726 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