Solved

Count Field in SQL

Posted on 2006-11-21
2
286 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
2 Comments
 
LVL 142

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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Suggested Solutions

All XML, All the Time; More Fun MySQL Tidbits – Dynamically Generate XML via Stored Procedure in MySQL Extensible Markup Language (XML) and database systems, a marriage we are seeing more and more of.  So the topics of parsing and manipulating XM…
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.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

920 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

13 Experts available now in Live!

Get 1:1 Help Now