This message was edited by infidel at 2004-11-15 7:54:15
: : : Hi,
: : :
: : : I have table with four columns (A, B, C, D).
: : : I need something like this :
: : :
: : : SELECT COUNT(A) FROM MyTable GROUP BY A, B, DISTINCT(C), DISTINCT(D)
: : :
: : : But I can use DISTINCT in GROUP BY clause. How can I write it using legal SQL query ???
: : :
: : : I will really thanful you if you help me, much thanks.
: :
: : Using distinct in a group by clause doesn't even make sense. When you say "group by" something that means find all the records that have the same value in that field and aggregate them together.
: :
: : I'm not exactly sure what you're trying to do. Your example doesn't make enough sense for me to guess.
: :
: :
: :
infidel
: :
: :
: : $ select * from users where clue > 0
: : no rows returned
: :
: :
: :
:
: I mean this : I want to group rows with same A, same B, unique C, unique D.
:
Ok, how about:
select ...
from table
group by A, B
Unless you explicitly group by a column, it is not grouped, so there's no need to use any distinct qualifier for the other columns.
infidel
$ select * from users where clue > 0
no rows returned