Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 309
  • Last Modified:

Count Field in SQL

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
raju1
Asked:
raju1
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
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
 
raju1Author Commented:
it doesn't show any result.

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

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

Tackle projects and never again get stuck behind a technical roadblock.
Join Now