Question: I'm using post title for url hash, like this:

```
window.location.hash = news_title;

```

Yes, it works good but like this:

```
http://example.com/news.html#This%20Is%20Kul%C3%BCb%C3%BC%20%E2%80%93%20News%20Build

```

Because some titles contain spaces and special characters.

I tried that but its not working:

```
window.location.hash = project_name;
var hash = window.location.hash;
hash = hash.replace('%20', '-');

```

What should I do? Thanks!

Answer: 
That is correct behavior for SQL Server. Some databases allow aliases in the `GROUP BY`. SQL Server is not one of them.

Databases are also inconsistent about aliases in the `HAVING` clause. However, most databases allow aliases in the `ORDER BY` -- some (such as Hive) even require aliases there, not allowing functional expressions.
Use can use `cross apply` if you don't want to repeat the expression twice 

```
SELECT ca.DOW,
       Revenue = Sum(subtotal),
       Orders = Count(*),
       RPO = Sum(subtotal)
FROM   sales.salesorderheader
       CROSS apply (SELECT Datename(dw, orderdate)) ca (DOW)
WHERE  Year(orderdate) = 2008
       AND OnlineOrderFlag = 0
GROUP  BY ca.DOW
ORDER  BY RPO DESC 

```