Solved

Count Field in SQL

Posted on 2006-11-21
2
283 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
Comment Utility
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
Comment Utility
it doesn't show any result.

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

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Fore-Foreword Today (2016) Maxmind has a new approach to the distribution of its data sets.  This article may be obsolete.  Instead of using the examples here, have a look at the MaxMind API (https://www.maxmind.com/en/geolite2-developer-package). …
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…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

744 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