Solved

Count Field in SQL

Posted on 2006-11-21
2
296 Views
Last Modified: 2008-01-09
Dear Experts,

I have a table( id, duration) and its data are as follows:

id          duration
=          =====
1           0
2           5
3           0
4           1
5           2
6           9

I want a result by SQL query with the following two fields:
Count(duration only 0)   Count(duration not 0)
==============   ==============
2                                 4

0
Comment
Question by:raju1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 50 total points
ID: 17986963
select  sum ( case when  duration = 0 then 1 else 0 end ) duration_0
, sum ( case when  duration = 0 then 0 else 1 end ) duration_not_0
from yourtable
0
 

Author Comment

by:raju1
ID: 17987118
it doesn't show any result.

Error message:
"Function Sum does not exist;"
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

I have been using r1soft Continuous Data Protection (http://www.r1soft.com/linux-cdp/) for many years now with the mySQL Addon and wanted to share a trick I have used several times. For those of us that don't have the luxury of using all transact…
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

630 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