Use max() instead of ternary in DB offset.