I have "Episode" content type and some "Showing from" date field in it which is repeating (more than one value can be added). Then I have a view that list episodes ordered by that field, which works, but I want to exclude same episodes. Now if episode has i.e. 3 times that fulfill filter criteria episode will be listed 3 times. I checked "Distinct" option but it doesn't help - still episode is listed 3x. Actually I'm not very sure how Distinct works - is it possible to select a filed that has to be distinct (if yes - how?) or it works for all fields? I would like to set distinct on episode nid of course.
2 Answers
- Apply a filter on the date field
- Select the operator: 'Is equal to', and type '0'
When you have a multiple value field, the field has a list or array of values. delta=0 is the first value
for that you can use aggregation with views i.e in advanced option in views from their you can use aggregation yes, and in that field click agregation settings set your option as distinct
-
I tried with grouping but without success. When I just turn on aggregation I got mySql error. Also, for all fields in their aggregation settings it's pre-select "Group results together". And there is no "Distinct" option to select?! There is "Count DISTINCT", but when I set that I get no results at all?! Where can I set that "distinct" option for specific field? Commented Aug 11, 2014 at 11:18
-
To be more precise if I turn on aggregation and in format settings I select the field I want to group by (node id) I get mySql error: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AS field_data_field_img_, field_data_field_show.field_show_nid AS field_data_fie' at line 1 Commented Aug 11, 2014 at 12:12
-
And the query I get starts with: SELECT DISTINCT field_data_field_img. AS field_data_field_img_, field_data_field_show.field_show_nid AS field_data_field_show_field_show_nid, field_data_field_season.field_season_value AS field_data_field_season_field_season_value, field_data_field_episode.field_episode_value AS field_data_field_episode_field_episode_value, field_data_body.body_value AS field_data_body_body_value, node.nid AS nid_1, node.title AS node_title, field_data_field_video_id.field_video_id_value AS field_data_field_video_id_field_video_id_value, node.created ... Commented Aug 11, 2014 at 12:15
-
First field that I'm getting is image from that "episode" content type, but it "field_data_field_img." looks suspicious to me - every where else is something.something and for image field variable after dot is missing. Commented Aug 11, 2014 at 12:16
-
Is image field somehow specific? Do I have to set something there when I turn on aggregation? Commented Aug 11, 2014 at 12:17