How do I do a simple GROUP BY? I've got a view which represents a list of redirects. The view has two fields:


'Destination'
'Source'
'Hash' (an indexed has based on the destination)


I'd like to generate a view which lists destinations along with the number of times a visitor has been redirected to that destination. If I were to write the SQL myself, I'd simply do:

SELECT destination, count(*) as redirects FROM redirects GROUP BY hash


However, no matter what I do I can't get Views to ONLY group by hash. This is what I've done:


Enabled aggregation (Advanced > Aggregation>
Enabled COUNT on the 'source' field.


What happens now is that Views COUNT on the 'source' field, but groups on both the 'destination' AND 'hash' field:

SELECT destination, hash, COUNT(source) FROM redirects GROUP BY destination, hash


How do I get Views to only GROUP BY the 'hash' field?
I am not 100% sure but I would suggest you simply do the following:


Choose Format = Table
Then click on the settings for Table
Change the grouping field to the "hash" field




Then aggregate the results based on the destinations. 

However, when you use the redirect module in Drupal 7 there is a field available called "Redirect: Clicks". I wonder if this may help you.

I hope this may helps.