2

I've got a view which represents a list of redirects. The view has two fields:

  1. 'Destination'
  2. 'Source'
  3. '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:

  1. Enabled aggregation (Advanced > Aggregation>
  2. 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?

1 Answer 1

1

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

enter image description here

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.