Wrap your code in code tags. Uppercase reserved words so it becomes easier to read your code, and making use of newlines and indenting is a good idea as well. At least if you want someone else to read your code. I didn't, but I can give you some generic information and create my own examples instead.
First off, do yourself a favor and do NOT utilize the MySQL extension (I prefer the word insanity in this case) to aggregate functions and grouping.
The standard states (for good reason), that every column must be part of either the group by clause or an aggregate function, if you group data.
Consider a person table with id, fname, lname, initials, where initials are first char of fname and lname (redundant data, but used to make a point).
SELECT id, fname
FROM person
obviously shows all persons
SELECT count(id), fname
FROM person
GROUP BY fname
Now, the output is grouped on first name, and for each such group, the ids are counted, which means the result shows how many people have the same fname.
SELECT count(id), fname, lname
FROM person
GROUP BY fname, lname
Same as above, but now both fname and lname must match.
On to MySQL's extension...
SELECT count(id), fname, lname, initials
FROM person
GROUP BY fname, lname
This code won't work with standard SQL, since initials is not part of the group by clause nor an aggregate function. However, initials is the same for all rows that are grouped together (obviously, since it's based on all the the things you group by), so this is "safe".
SELECT id, fname, lname
FROM person
GROUP BY fname, lname
This however, is not safe. Output will show ANY id AT ALL (still assuming you're using MySQL), from one of the rows that are grouped together. And you don't know which.
So start by dropping everything from your query which is neither in an aggregate function or the group by clause. Then inspect your values again. Feel free to post code and ask for more help, but you really should use code tags, line breaks etc. If your code isn't easily readable, there is low chance that anyone will read it.