mysql count problem

Discussion in 'Web Development' started by newphpcoder, Feb 21, 2012.

  1. newphpcoder

    newphpcoder New Member

    Joined:
    Sep 24, 2010
    Messages:
    101
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Web Programmer
    Location:
    Philippines
    Good day!
    Hi,
    I encountered problem in Count.
    I have this data:

    REFNUM----LOT_CODE----PCODE--wip_chemicalweighing--wip_compounding-------wip_extrusion--wip_forming--wip_deflashing
    000001----000001P35M--P35M---0.00------------------0.00------------------0.00-----------0.00---------40.00---------
    000002----000002P35M--P35M---73.30-----------------NULL------------------NULL-----------NULL---------NULL---------
    and I have this code:
    Code:
    SELECT PCODE, COUNT(LOT_CODE) AS lot_chemicalweighing, COUNT(wip_chemicalweighing + wip_compounding + wip_extrusion + wip_forming + wip_deflashing) AS virtual FROM kanban_data WHERE wip_chemicalweighing != '0.00' OR 'NULL' AND wip_compounding != '0.00' OR 'NULL' AND wip_extrusion != '0.00' OR 'NULL'AND wip_forming != '0.00' OR 'NULL' AND wip_deflashing != '0.00' OR 'NULL' GROUP BY PCODE;
    
    And the output of this code is :
    PCODE-- lot_chemicalweighing---virtual----
    P35M----1----------------------0--------
    the lot_chemicalweighing is correct but the virtual is wrong, because it should be 2 because I have 1 data in wip_chemicalweighing and 1 in wip_deflashing.
    Thank you
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice