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.

Thanks

Meena
-------

---------------------------------------------------------------------
Before posting, please check:
  http://www.mysql.com/manual.php   (the manual)
  http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to