0

I am having a query like this:

SELECT DISTINCT ?a ?b
WHERE { 
  ...
} ORDER BY DESC(?area)

but this will produce:

    a              b
"result1"       "item1"
"result2"       "item2"
"result3"       "item3"
"result4"       "item4"
"result4"       "item5" 

so I am wondering, since this is for my uni, if they do not want result4 twice, which happens because result4 is a component of item4 and item5.

So how can I tell that I want every variable to be distinct and not just the pair of a and b?

This:

SELECT DISTINCT ?l_name DISTINCT ?region_name

will produce an error:

Encountered " "distinct" "DISTINCT "" at line 10, column 25. Was expecting one of: "(" ... "{" ... "from" ... "where" ... ... ...

Kara
  • 6,115
  • 16
  • 50
  • 57
gsamaras
  • 71,951
  • 46
  • 188
  • 305
  • 1
    and by doing that- which one do you want to get? item4 or item5? – Nir Levy Jan 11 '16 at 20:02
  • 1
    "so I am wondering, since this is for my uni, if they do not want result4 twice" - You should ask whoever gave you the assignment; it may be a moot question. Also, why have you tagged this SQL? It appears to be pure SPARQL. Despite having similar syntaxes, they are very different and not compatible off the shelf. – Esoteric Screen Name Jan 11 '16 at 20:05
  • I do not care @NirLevy. Esoteric I did but I got no answer, so I would like to present both solutions! I removed it. – gsamaras Jan 11 '16 at 20:06
  • What natural language version of the query were you given to code? – philipxy Jan 11 '16 at 20:07
  • What is a translation of it? You haven't given the problem statement yet. – philipxy Jan 11 '16 at 20:14
  • Just to keep the question small @philipxy. Nir Levy provided a solution though. Thanks! – gsamaras Jan 11 '16 at 20:15
  • Possible duplicate of [Aggregating results from SPARQL query](http://stackoverflow.com/questions/18212697/aggregating-results-from-sparql-query) – Jeen Broekstra Jan 11 '16 at 20:19

1 Answers1

1

if you don't care about column b, simply don't select it.. put in your query only a:

SELECT DISTINCT ?a WHERE ....
Jeen Broekstra
  • 21,642
  • 4
  • 51
  • 73
Nir Levy
  • 12,750
  • 3
  • 21
  • 38