Comparison theory for Riccati equations