In a SQL Server query, we sometimes have nested queries that use values from the outer select statement, but if those values are used in the Group By, it could return more records than we expect.
The following example shows how to handle these types of queries without using Group By.