How would you count a column and return a count of numbers above 0 (zero)?

Right now it is counting anything in the column, including 0's.

Basically I want it to count how many rows have at least a 1 in it, and return that as a Games Played.

Thanks

    You could do it a few different ways.

    Here's a couple off the top of my head:

    
    $sql = "SELECT COUNT(column) AS games_played FROM table WHERE column > 0";
    
    $result = mysql_query($sql) or die ("Could not execute query: ".mysql_error());
    
    $row = mysql_fetch_object($result);
    
    echo $row->games_played;
    
    

    or

    
    $sql = "SELECT column FROM table WHERE column > 0";
    
    $result = mysql_query($sql) or die ("Could not execute query: ".mysql_error());
    
    $count = mysql_num_rows($result);
    
    echo $count;
    
    
      Write a Reply...