Second question in two days on this same sort of topic.
I currently am using the following query:
SELECT name,suite,webpagetest.id,MIN(priority) AS min_pri
FROM webpagetest,comparefileerrors
WHERE vco="aof" AND user="1" AND calibreversion="9"
AND webpagetest.id=comparefileerrors.id
AND comparefileerrors.priority IS NOT NULL
GROUP BY id,suite
ORDER BY COALESCE(suite,name),min_pri
ASC ;
This gives me results that look as follows:
+-----------------------------+-----------------------------+-------+---------+
| name | suite | id | min_pri |
+-----------------------------+-----------------------------+-------+---------+
| bz1273_cmdline_execplussvdb | NULL | 6203 | 2 |
| bz1508_SEGV_password | NULL | 6185 | 2 |
| bz1747_bad_lvsf | NULL | 36683 | 1 |
| set_get_status | shortsRepairDB_2009.1_suite | 6193 | 0 |
| u2uDemo | shortsRepairDB_2009.1_suite | 6195 | 0 |
| change_sets | shortsRepairDB_2009.1_suite | 6194 | 0 |
| add_delete_mask_polygon | shortsRepairDB_2009.1_suite | 6191 | 0 |
| isolate_shorts | shortsRepairDB_2009.1_suite | 6196 | 0 |
| add_delete_text | shortsRepairDB_2009.1_suite | 6197 | 0 |
| assign_short_AND_user_info | shortsRepairDB_2009.1_suite | 6198 | 2 |
| comment_short | shortsRepairDB_2009.1_suite | 6192 | 2 |
+-----------------------------+-----------------------------+-------+---------+
However, what I would like to do is order them by the minimum priority that is encountered in suite, if there is one. Suite is an optional field, and if it is null, then there is no need to do this grouping. I want to use the minimum value in the suite determine the overall placement of the suite.
I am heavily considering redesigning my app to use PHP to do this sorting, but for the mean time, it would be nice to do this with mysql.
The results should look like the following:
+-----------------------------+-----------------------------+-------+---------+
| name | suite | id | min_pri |
+-----------------------------+-----------------------------+-------+---------+
| set_get_status | shortsRepairDB_2009.1_suite | 6193 | 0 |
| u2uDemo | shortsRepairDB_2009.1_suite | 6195 | 0 |
| change_sets | shortsRepairDB_2009.1_suite | 6194 | 0 |
| add_delete_mask_polygon | shortsRepairDB_2009.1_suite | 6191 | 0 |
| isolate_shorts | shortsRepairDB_2009.1_suite | 6196 | 0 |
| add_delete_text | shortsRepairDB_2009.1_suite | 6197 | 0 |
| assign_short_AND_user_info | shortsRepairDB_2009.1_suite | 6198 | 2 |
| comment_short | shortsRepairDB_2009.1_suite | 6192 | 2 |
| bz1747_bad_lvsf | NULL | 36683 | 1 |
| bz1273_cmdline_execplussvdb | NULL | 6203 | 2 |
| bz1508_SEGV_password | NULL | 6185 | 2 |
+-----------------------------+-----------------------------+-------+---------+