Ideal Concepts Interview Question

Sql code output, c++, probability