List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:January 9 2003 6:24pm
Subject:Re: count(expr)
View as plain text  
At 10:29 -0600 1/9/03, Meena Vyavahare wrote:
>Here is my query-
>Select col1, col2, count(*) as total, count(col3 < col4) as violations
>from table1
>Where condn
>group by col1, col2
>The result of this query shows same values at both the columns for total
>and violations.
>The count(expr) does not work????

Sure it does.  It's counting non-NULL values.  If no values in col3 or
col4 are NULL, then col3 < col4 evaluates to either 0 or 1 and is
counted, and your total will be the same as COUNT(*).

You probably want SUM(col3 < col4,1,0) instead.


count(expr)Meena Vyavahare9 Jan
  • Re: count(expr)Paul DuBois9 Jan
  • Re: count(expr)Keith C. Ivey9 Jan
Re: count(expr)Paul DuBois10 Jan