Question: I have some server side code in `PHP` which looks like this

```
$var2 = htmlspecialchars($var1);

```

For example,

```
"It's Monday" gets converted to "It&#039;s Monday"

```

I am not able to decode the text back in javascript using the function [unescape.](http://www.w3schools.com/jsref/jsref_unescape.asp) 

```
unescape("It&#039;s Monday") // returns "It&#039;s Monday"

```

How can i decode this in javascript to get the original string back, apart from using [replace](http://www.w3schools.com/jsref/jsref_replace.asp) (because this way i'd have to manually handle all special cases) ?

Answer: 
You should be able to use the following:

```
select x.id, x.group_id, x.itemname, count(y.id) as sort, x.type
  from tbl x
  left outer join tbl y
    on x.group_id = y.group_id
   and y.id < x.id
 group by x.id, x.group_id, x.itemname, x.type

```

See fiddle at:
<http://sqlfiddle.com/#!2/bc4e8/3/0>

I know that I used mysql in that fiddle but I am not using any syntax not supported by Access, I don't believe. The only thing you might have to do is enclose the on clause in () , I forget how the on clause works with Access but know it is bizarre.
Updated for comment:
You can use:

```
 Select * from (
 Select * from yourTableName ORDER BY yourTableName.Sort)
 ORDER BY yourTableName.GroupID

```

When you create simple query, go to the SQL mode and insert the code.