Actually, my query is something like
SELECT ... FROM ... WHERE `pid` = (SELECT `id` FROM ...);
if i put that group by... will it group all rows, or only those with
the same pid?
Use a subquery
SELECT price, sum(count) FROM (
-- your original query here
SELECT price, count FROM ... WHERE `pid` = (SELECT `id` FROM ...)
) GROUP BY price;
And you treat your subquery as just any other table. That way it's clear
where your GROUPing is applied.
Side note: I'd be careful about naming columns names like 'count'. That's a
function in SQL, and some will simply not allow you to use it as a column
name. Some will allow you to use it as a column name with some special
handling (like "[count]"). SQLite appears to allow a column named "count",
but did not for some others ("limit" comes to mind). "Precision" is another
example in SQLServer.. It's easy to get around, just prepend some
description to the word, like "UnitPrice, ItemCount"...
Regards,
Trey
-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------