In The Analects of Confucius, Confucius famously said, "See the sage Si Qi, but if you don't see the sage, you should reflect on yourself.". The "virtuous" and "not virtuous" here refer to the level of human ability.
Another famous saying of Confucius in The Analects of Confucius is "Choose those who are good and follow them, and change those who are not good". The "good people" and "bad people" here refer to the advantages and disadvantages of people according to moral norms.
It is precisely because people's success or failure is related to their own ability level and their own advantages and disadvantages, so the famous saying of Emperor Taizong, "Learn from others, and you can know the gains and losses" can be completely related to the famous saying of Confucius in The Analects of Confucius, "See the sages and Si Qi, but look back when you don't see them" and "Choose those who are good and follow them, and change those who are not".