Imagine we have a table like this:
id value
1 a
2 b
3 a
4 a
5 b
Query like this
SELECT * , COUNT( * )
FROM test
GROUP BY value
gives us a table like this:
id value COUNT(*)
1 a 3
2 b 2
which tells us that there are three 'a' and two 'b' in our table.
The question is: is it possible to make a query (without nested SELECT's), which would yield a table like
id value count_in_col
1 a 3
2 b 2
3 a 3
4 a 3
5 b 2
The goal is to avoid collapsing columns and to add quantity of 'value' elements in the whole column to each row.