Question: I'm seeking some help on how I can click the "Play Activity button" in our Global Productivity Hub in our office using excel VBA. I'm creating an attendance log in tool with lunch and break trackers. Once the employee click Log In with tool that I created, the GPH site will launch and will logged them in, the same thing with Log Out. However, I'm having difficulty in controlling the break and lunch button of GPH site using the tool that I created. I cannot find the correct elements to integrate to my vba code. I hope someone can help me with this. Please see below the HTML code of that particular button and the image.

```html
<tr class="top-five">
    <td title="Play Activity" class="glyphicon glyphicon-play-circle play-activity" data-toggle="tooltip" data-team-id="e9575e8b-4682-734c-b28d-b1ee5532a8ce" data-activity-id="e0728017-a4fa-ef4b-91a6-262e5418a134" data-team-name="Technology Team"> </td>
 <td> 
   <span title="Break Activities" class="act-ellipsis" data-toggle="tooltip">
<span class="ellip ellip-line"> Break Activities </span>

</span>
 Break
</td> 

<td title="Favorite" class="glyphicon glyphicon-star" data-toggle="tooltip" data-activity-id="e0728017-a4fa-ef4b-91a6-262e5418a134"></td>

</tr>
```

![Image](https://i.stack.imgur.com/Ct5QD.jpg)

Answer: 
You could use a rank analytic function here, e.g.

```
SELECT salary
FROM
(
    SELECT salary, DENSE_RANK() OVER (ORDER BY salary DESC) dr
    FROM c
) t
WHERE dr = 2;

```

This would return the second highest salary by dense rank, including all ties for second.
Explanation why your subquery can't work:

1. At first, records are read from the table in an arbitrary order. This is when they get their `rownum`.
2. Then aggregation takes place; all records for one `salary` are condensed to a single row. The `rownum` of the single rows you had before are no longer available.
3. Then the aggregated rows are filtered by `HAVING`, and this cannot work, as you are trying to access `rownum`. Moreover, conditions on `rownum = 2` always fail, because you are dismissing the first row, so it is "not read" and `rownum` 1 is still available, you dismiss the second, because you haven't even read `rownum` 1 yet, and so on. Criteria on `rownum` is always `rownum <= some_number` (except for 1 where you can have `rownum = 1`).
4. The last thing that happens is the sorting; the `ORDER BY` clause belongs at the end of the query hence. (It can only be followed by `FETCH FIRST n ROWS` as of Oracle 12c.)

Here is how to make it work with `rownum`:

```
select salary
from
(
  select salary
  from
  (
    select distinct salary 
    from c
    order by salary desc
  )
  where rownum <= 2
  order by salary
)
where rownum = 1;

```

This works, because Oracle is violating the SQL standard here. According to the standard, data from subqueries is considered unordered, but Oracle guarantees the order when working with `rownum`.

Here is how to do it with aggregation:

```
select max(salary) from c where salary < (select max(salary) from c);

```

Since Oracle 10 you can also use analytic functions as shown in Tim's answer.