Subject | Re: GROUP BY |
---|---|
Author | Svein Erling |
Post date | 2003-07-24T21:01:05Z |
> and this?BY P1)
>
> SELECT P1,P2,P3 FROM TABLE1 WHERE P1 IN (SELECT P1 FROM TABLE GROUP
I guess it would not compile since I don't think GROUP BY is allowed
in subselects, but the biggest problem is that it doesn't make any
sense at all.
The best way to write something like this would be either:
SELECT DISTINCT TABLE1.P1, TABLE1.P2, TABLE1.P3
FROM TABLE1
JOIN TABLE ON TABLE.P1 = TABLE1.P1
or
SELECT TABLE1.P1, TABLE1.P2, TABLE1.P3
FROM TABLE1
WHERE EXISTS(SELECT * FROM TABLE WHERE TABLE.P1 = TABLE1.P1)
Using GROUP BY on only some columns when the others are not aggregate
doesn't make any sense.
If this isn't a satisfactory answer, please tell us what you are
trying to do. Then I'm sure we can tell you how it is to be done - if
possible.
Set