This is a sample from the base according to the conditions: Source array:
0 : { group: "1", value: "4"} 1 : { group: "1", value: "4"} 2 : { group: "1", value: "8"} 3 : { group: "2", value: "2"} 4 : { group: "2", value: "8"} 5 : { group: "2", value: "8"} The question is, is it possible to group the elements with the MySql query, provided that only the value elements from their group can be grouped?
The final grouping variant should be such an array:
0 : { group: "1", value: "4"} 2 : { group: "1", value: "8"} 3 : { group: "2", value: "2"} 4 : { group: "2", value: "8"}
case when .... then .... else ... end. They can be put one-on-one (tree), - and make a conditional group of any complexity. - nick_n_aselect distinct group, value from table. Or, if the number that is in front of the parentheses is the same in the database and is needed, then an elementary group by in these two fields, and then the field in front of the parentheses, for example min () - Mike