Question: I have an Excel Table named Table5 which consist of two columns CompanyCode and EmployeeLevel. Now my question is i want to get the unique values of EmployeeLevel columns. Take note that the length of the record is unknown. I am using the Table5[EmployeeLevel] as the range to include all the records in the Table5. Is there a formula that you can provide ? I cannot use ActiveX object to loop through each record. I must do it via Excel formula. The solutions I got are only usable when it is fixed how long the records are. but this record I am working on is a dynamic table. 

Thanks in advance :)

Answer: 
Like @Grim said, you can use `INNER JOIN` instead of `LEFT JOIN`. However, if you truly look for optimization, I would suggest you to have an extra field at table `users` with a precalculate `point`. This solution would beat any query optimization with your current database design.
It doesn't really matter than you are getting only 10 rows. MySQL has to sum up the points for every user, before it can sort them ("Using filesort" operation.) That LIMIT is applied last.

A covering index `ON points(user_id,point)` is going to be the best bet for optimum performance. (I'm really just guessing, without any `EXPLAIN` output or table definitions.)

The `id` column in `users` is likely the primary key, or at least a unique index. So it's likely you already have an index with `id` as the leading column, or primary key cluster index if it's InnoDB.)

I'd be tempted to test a query like this:

```
 SELECT u.*
      , s.total_points
   FROM ( SELECT p.user_id
               , SUM(p.point) AS total_points
            FROM points p
           WHERE p.user_id > 0
           GROUP BY p.user_id
           ORDER BY total_points DESC
           LIMIT 10
        ) s
   JOIN user u
     ON u.id = s.user_id
  ORDER BY s.total_points DESC 

```

That does have the overhead of creating a derived table, but with a suitable index on points, with a leading column of user\_id, and including the point column, it's likely that MySQL can optimize the group by using the index, and avoiding one "Using filesort" operation (for the GROUP BY).

There will likely be a "Using filesort" operation on that resultset, to get the rows ordered by total\_points. Then get the first 10 rows from that.

With those 10 rows, we can join to the user table to get the corresponding rows.

BUT.. there is one slight difference with this result, if any of the values of `user_id` that are in the top 10 which aren't in the user table, then this query will return less than 10 rows. (I'd expect there to be a foreign key defined, so that wouldn't happen, but I'm really just guessing without table definitions.)

An `EXPLAIN` would show the access plan being used by MySQL.