?
Solved

Oracle SQL - Count multiple fields

Posted on 2008-06-13
4
Medium Priority
?
3,899 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
2 Comments
 
LVL 29

Accepted Solution

by:
MikeOM_DBA earned 252 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 248 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
Working with Network Access Control Lists in Oracle 11g (part 2) Part 1: http://www.e-e.com/A_8429.html Previously, I introduced the basics of network ACL's including how to create, delete and modify entries to allow and deny access.  For many…
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
Suggested Courses
Course of the Month16 days, 14 hours left to enroll

864 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