Question: I have a query that i get the MAX number of "stars"

```
 <cfquery datasource="Intranet" name="getMaxstars">
SELECT   TOP (1) WITH TIES employee, SUM(execoffice_status) AS 'total_max'
FROM     CSEReduxResponses
GROUP BY employee
ORDER BY 'total_max' DESC
</cfquery >

```

I also have a different table EMPLOYEE. Table EMPLOYEE also comes from a different datasource="phonelist". Where in this table I have the employees first\_name and last\_name columns , they share the same column emp\_id.
How can I output the employee first\_name and last\_name using the other table. 

What I eventually I want to do it output:
max:
john doe - stars = 4

Answer: 
Use a subquery like below:

```
select employee_id, sum(stars) as num_stars
  from table_a
 group by employee_id
having sum(stars) = (select max(num_stars)
                       from (select employee_id, sum(stars) as num_stars
                               from table_a
                              group by employee_id) x)

```
```
SELECT   TOP (1) WITH TIES employee_id, SUM(stars) AS 'total'
FROM     Table_A
GROUP BY employee_id
ORDER BY 'total' DESC

```

This is an alternative method.