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
DATAwill be selected,GROUP BYis nice, though using ungrouped and unaggregated columns inSELECTclause of aGROUP BYstatement isMySQLspecific and not portable.