I did a search to see if there was an issue created for this yet. I didn't see one.
I hope this helps.

An AJAX HTTP error occurred.
HTTP Result Code: 500
Debugging information follows.
Path: /admin/structure/views/ajax/preview/<my view>
StatusText: Service unavailable (with message)
ResponseText: Exception: d7cx: Column-level distinct is not supported yet. in views_plugin_query_default-&gt;compile_fields() (line 900 of /home/user/site.com/sites/all/modules/views/plugins/views_plugin_query_default.inc).
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dawehner’s picture

As you can read in the error message. This feature is not support by dbtng at the moment.

gr33nman’s picture

Thanks for your reply. If this type of input is not helpful, please let me know.

dawehner’s picture

Title: Ajax error when selecting 'Distinct: Yes' in Views/edit/<my view> » Distinct is not supported by dbtng
Status: Needs work » Active

.

esmerel’s picture

Status: Active » Closed (won't fix)

Really, this is more like "Can't fix", but once dbtng supports it, this might need revisiting.

gr33nman’s picture

Okay - good to know the limits of views in D7. Thanks.

Unnamed’s picture

FileSize
25.6 KB

I have a similar problem.

There's concluded views in which the same information.
If I set the value of Distinct: Yes, it appears a similar error:

(D7-dev, Views-dev)

mfer’s picture

Status: Closed (won't fix) » Postponed

No field level distinct should have been filed against core. Now that it has this should be postponed until that is fixed. See #975936: No Field Level Distinct Query Support

Damien Tournoud’s picture

Status: Postponed » Active

This is a Views bug.

*I* added that exception to the code. Column-level distinct is a myth. What Views needs to use is a GROUP BY, and Views needs to decide what to do with the non-grouped fields.

Damien Tournoud’s picture

Status: Active » Needs review
FileSize
1.33 KB

As Dave Reid pointed out, Views already adds a GROUP BY in that case. Fixing the immediate bug should then be as easy as this.

dawehner’s picture

query->distinct() is never called.
Uncommented the stuff out and moved a bit around.

This works for me.

Just as a notice, groupby and distinct together removes the "distinct"-feature by adding the base field to the groupby.

Damien Tournoud’s picture

-      $base_field_alias = $this->add_field($this->base_table, $this->base_field, NULL, array('distinct' => TRUE));
+      $base_field_alias = $this->add_field($this->base_table, $this->base_field);
+      $query->distinct();
       $this->add_groupby($base_field_alias);

The point is: we don't want nor need this. The add_groupby is all that matters.

     // Make the query distinct if the option was set.
     if (!empty($this->options['distinct'])) {
-      // $this->set_distinct();
+      $this->set_distinct();
     }

Hm. What explains that clicking on this damn checkbox in the UI does something then?

dawehner’s picture

$this->set_distinct set's $this->distinct

And

    if (empty($this->no_distinct) && $this->distinct && !empty($this->fields)) {
      $base_field_alias = $this->add_field($this->base_table, $this->base_field, NULL, array('distinct' => TRUE));
      $this->add_groupby($base_field_alias);
    }

needs this flag.

dawehner’s picture

So what about this patch.

mfer’s picture

Does this mean no row level distinct support in Views? If not, how will distinct be handled?

Scott Reynolds’s picture

Status: Needs review » Reviewed & tested by the community

This worked great guys, thanks!

dawehner’s picture

Status: Reviewed & tested by the community » Fixed

Thanks

Commited to the 7.x branch.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.