-----Original Message-----
From: zlab1 [mailto:[EMAIL PROTECTED]] 
Sent: Sunday, April 21, 2002 13:50
To: MySQL Mailing List ([EMAIL PROTECTED])
Subject: Problem with HAVING


Hi,

    I'm running Mysql 4.01 on mandrake 8.2 with all production data
using InnoDB type.

I've a field named "dch_pri" contain some account transaction data in
format of DECIMAL (14,2).

When running following query:

SELECT din_no, SUM(IF(tran_type = "D", dch_pri, -dch_pri)) AS dch_sum
        FROM pa_ch2
        WHERE   x_status IN ("", "C")
                AND dch_acc IN ('231000', '310000')
        GROUP BY din_no
        HAVING dch_sum # 0

It remove all record that contain absolute value between 0 and 0.99

Change query to:

SELECT din_no, SUM(IF(tran_type = "D", dch_pri, -dch_pri)) AS dch_sum
        FROM pa_ch2
        WHERE   x_status IN ("", "C")
                AND dch_acc IN ('231000', '310000')
        GROUP BY din_no
        HAVING dch_sum <> 0

It will retain all result record which  dch_sum = 0

Change the HAVING dch_sum # 0 to HAVING dch_sum # 0.00
Or 
Change the HAVING dch_sum <> 0 to HAVING dch_sum <> 0.00 Doesn't
improve. Any idea?


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