SQL & Queries

Answer & solution
Official answer: 5
1. Read the actual WHERE clause before inferring the intended relationship. It contains P.Marks>84 but no condition S.Roll_no=P.Roll_no. Listing both tables in FROM therefore forms their Cartesian product, not a join on the similarly named columns.
2. Five Performance rows pass the filter: marks 86,95,90,89,92. The 80-mark row is excluded. Each of the five Student rows pairs with every one of these five surviving rows, yielding 25 intermediate rows.
3. GROUP BY S.Student_name partitions those rows by the five distinct student names. Each group has five rows and the same marks sum: 86+95+90+89+92=452.
4. The result is (Amit,452), (Priya,452), (Vinit,452), (Rohan,452), (Smita,452), in unspecified order. Hence the requested row count is 5.
5. Rohan and Smita are included even though they have no Performance records: the query never correlates a performance with its owner. Primary keys do not automatically add a join predicate. Adding that missing predicate would answer a different query and must not be silently done.