From: Jim B. <ba...@ne...> - 2014-11-05 23:14:42
|
> On Nov 5, 2014, at 5:46 PM, Jeremy J Carroll <jj...@sy...> wrote: > > >> On Nov 5, 2014, at 1:02 PM, Bryan Thompson <br...@sy...> wrote: >> >> There could be an issue with ORDER BY operating on an anonymous and non-projected variable. Try declaring and binding a variable for STR(?label) inside of the query and then using that variable in the ORDER BY clause. > > > Yes I tend to find the results of ORDER BY are more what I expect if I do not include an expression in the ORDER BY but simply variables. I BIND any expression before the ORDER BY. > > I believe there is a trac item for this, but since the workaround is easy, I have never seen it as high priority > As suggested I tried binding a variable as `BIND (STR(?term_label) AS ?string_label)` and using that to sort. Still incorrect ordering. But, I tried removing DISTINCT, and then the ordering is correct. Even going back to the anonymous `ORDER BY STR(?term_label)`, ordering is still correct if I remove DISTINCT. For this specific query DISTINCT is not needed, but I do need it for my application. Is there a reason to not expect DISTINCT to work correctly with ORDER BY? Thanks both of you for all of your help, Jim |