Overuse of individuals in a group?
I am looking at some SQL queries in SAS and I came across the following query structure:
SELECT distinct A, B, Sum(C) FROM Table1 GROUP BY A, B;
I would like to know if this is strict:
SELECT A, B, Sum(C) FROM Table1 GROUP BY A, B;
Or, if I am missing a nuance, in the output or way of processing calculations
+3
source to share
1 answer
The two queries are equivalent.
At all,
SELECT DISTINCT a, b, c
FROM <something>
equivalent to
SELECT a, b, c
FROM <something>
GROUP BY a, b, c
In your case <something>
is the result of a query GROUP BY
that has different columns A
and B
. This is enough to ensure that the triplets are A, B, SUM(C)
also unique.
+4
source to share