A query in a system I maintain returns
QID AID DATA
1 2 x
1 2 y
5 6 t
As per a new requirement, I do not want the (QID, AID)=(1,2) pair to be repeated. We also dont care what value is 开发者_运维问答selected from "data" column. either x or y will do.
What I have done is to enclose the original query like this
SELECT * FROM (<original query text>) Results group by QID,AID
Is there a better way to go about this? The original query uses multiple joins and unions and what not, So I would prefer not to touch it unless its absolutely necesary
If you don't care which DATA
will be selected, GROUP BY
is nice, though using ungrouped and unaggregated columns in SELECT
clause of a GROUP BY
statement is MySQL
specific and not portable.
精彩评论