On 9 Jan 2003, at 10:29, Meena Vyavahare wrote:

> 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????

You're misunderstanding how COUNT() works.  Since the expression 
(col3 < col4) is never null, counting it is the same as counting the 
number of rows.  See the documentation:

   http://www.mysql.com/doc/en/Group_by_functions.html

In this situation you might use SUM() instead, since the inequality 
evaluates to either 0 or 1 in numeric context.

-- 
Keith C. Ivey <[EMAIL PROTECTED]>
Tobacco Documents Online
http://tobaccodocuments.org
Phone 202-667-6653

---------------------------------------------------------------------
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