I recived some great help earlier today but it was more difficult when I should implement it in my query than I thought. My real query includes several left joins.
I wa
It is a bit tricky, maybe is it this what you are looking for?
SELECT
q2.*,
CASE WHEN @row>1 AND T1G is not NULL THEN @row:=@row-1 ELSE 1 END T1GOutput
FROM (
SELECT
q1.*,
CASE WHEN @row>1 AND T3M is not NULL THEN @row:=@row-1 ELSE 1 END T3MOutput
FROM (
SELECT
base.number as NR,
rank.rpo as RPO,
rank.rsp as RSP,
rank.rsv as RSV,
timer.t3m as T3M,
timer.t1g AS T1G
FROM
round LEFT JOIN base
ON round.id = base.round_id
LEFT JOIN rank
ON round.id = rank.round_id and rank.number = base.number
LEFT JOIN timer
ON round.id = timer.round_id and timer.number = base.number
order by T3M DESC
) q1, (SELECT @row:=11) rows
) q2, (SELECT @row:=11) rows
ORDER BY
T1G
Please see fiddle here.