I'm trying to do a simple select where the returned rows are order by the result of a split count result.
Table example:
According to the image, If I were to split by comma and order by count result of this split, at an ascending order, it would go something like this:
T1, T2, T3
T1, T2
T1
T3
T2
I've tried this query:
Select SomeCol FROM Table GROUP BY SomeCol Order BY Count(instr(SomeCol, ',')) ASC
This works if there isn't duplicity, but it needs to work if there is duplicity. It should be able to display duplicate rows ordered by the split count.
Read some similar solutions and came up with one based on the ones I read.
Select SomeCol FROM Table Order BY length( replace(SomeCol , ',', '') ) ASC