If you have a unique column (or set of columns) in the table, you can simply add another expression to GROUP BY. The expression must return a unique value for each line when collection_idnull, otherwise a constant is returned.
, id , - :
... GROUP BY collection_id, IF(collection_id IS NULL, id, 0)
GROUP BY , collection_id , , collection_id null. ( , id , , PRIMARY KEY - . , , .
... GROUP BY collection_id
, IF(collection_id IS NULL, col1, '')
, IF(collection_id IS NULL, col2, NULL)
, IF(collection_id IS NULL, col3, collection_id)