I need to order a result set based on a count, which is working fine, but there may be times when an override comes in to effect and I need to get that to take precedence. I'm not entirely sure how to go about it though. I thought I'd got it, but then I realised that it was actually sorting by no order at all, unless the override value was set, at which point it fell in to place where it was supposed to.
Basically it works like this:
SET @i = 0;
, IF (t2.pos, t2.pos, @i:=@i+1) pos
, count(*) counter
ON t1.id = t2.id
I think that's right. What's basically happening is that the override value is positioning the row where it's supposed to in the resultset, but the rest of the data is out of order. Help!