Question: I'm trying to return the last time entry posted for a particular client, and the case (matter) number associated to that entry. The relationship is one client has many matters, and one matter has many time entries.

I have the code below, but it obviously returns all the matters and not just the one associated to the time entry. I understand why, but tie myself in knots when trying to correct it. Any help much appreciated.

```
select c.CLIENT_CODE,
       c.CLIENT_NAME,
       c.OPEN_DATE,
       mp.EMPLOYEE_NAME,
       MAX(tt.TRAN_DATE)[Last Time],
       m.MATTER_NUMBER
from HBM_CLIENT c
join HBM_MATTER m
 on m.CLIENT_UNO=c.CLIENT_UNO
left join TAT_TIME tt
 on tt.MATTER_UNO=m.MATTER_UNO
left join HBM_PERSNL mp
 on mp.EMPL_UNO=c.RESP_EMPL_UNO
where c.STATUS_CODE = 'Targ'
group by c.CLIENT_CODE,
         c.CLIENT_NAME,
         c.OPEN_DATE,
         mp.EMPLOYEE_NAME,
         m.MATTER_NUMBER
order by OPEN_DATE

```

Answer: 
How about just add the links to your existing code? See the `<a href="#">` in the example below:

```
$( "#chatscroll" ).html( $( "#chatscroll" ).html().replace('Fighting Moose Knuckles', '<a href="#"><img src="http://larryvasta.com/football/img/icons/Moose_Icon.png" /></a>') );

$( "#chatscroll" ).html( $( "#chatscroll" ).html().replace('Grundle Goblins', '<a href="#"><img src="http://larryvasta.com/football/img/icons/Goblins_Icon.png" /></a>') );

$( "#chatscroll" ).html( $( "#chatscroll" ).html().replace('Commissioner', '<a href="#"><img src="http://larryvasta.com/football/img/icons/Commish_Icon.png" /></a>') );

```
Try to use [`.wrap()`](http://api.jquery.com/wrap/) at this context, 

```
$('#chatscroll img').wrap('<a href="yourLink.com"></a>');

```