COUNTing total GROUPed rows

    Date: 11/29/07 (MySQL Communtiy)    Keywords: no keywords

    SELECT
        COUNT( * )
    FROM
        customers
        LEFT JOIN orders ON customers.id = orders.id
    WHERE
        YEAR( orders.order_date ) =2007 AND
         orders.total <= 1500
    GROUP BY
       orders.id

    I need to find the total number of customers who ordered at least 1500 in the year 2007.   This query returns the number of grouped orders.id instead (an array of counts instead of one global count for all the rows). 

    I know this is something simple I'm overlooking, but I've looked at this for a few minutes now and can't see what I'm doing wrong.  Help please?

    ANSWER
    SELECT COUNT(*) FROM (query above) AS grand_total;

    Source: http://community.livejournal.com/mysql/121631.html

« Faulty query || Problem with GROUP BY »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home