title: SPARQL query for preferred names of subclasses and their one top upper class
body: <p>I'm new to SPARQL.  I would like to get the preferred name of classes and their one top level upper classes and also their synonyms in the <a href="http://bioportal.bioontology.org/ontologies/RADLEX" rel="nofollow noreferrer">Radlex ontology, as hosted at BioPortal</a>.</p>
  
  <p>And The Output I want to see:
  <a href="http://bioportal.bioontology.org/ontologies/RADLEX" rel="nofollow noreferrer">output</a></p>
  
  <p><strong>Term</strong>: equal density
  <strong>subClassOf</strong>: density descriptor
  <strong>Synonym</strong>: isodens, equal-density,isodense</p>
  
  <p>It looks like, the code below solved my problem, but still requires some modification. Because, it brings all off the upper classes but I only want one level upper class.</p>
  
  <pre><code>PREFIX rdfs: &lt;http://www.w3.org/2000/01/rdf-schema#&gt;
  
  SELECT DISTINCT  ?concept ?subClassOf
  WHERE
  { GRAPH &lt;http://bioportal.bioontology.org/ontologies/RADLEX_OWL&gt;
    { ?term  a &lt;http://bioontology.org/projects/ontologies/radlex/radlexOwl#radlex_metaclass&gt; ;
          &lt;http://bioontology.org/projects/ontologies/radlex/radlexOwl#Preferred_name&gt;  ?concept
    }
    ?term rdfs:subClassOf ?upperClass. 
    ?upperClass &lt;http://bioontology.org/projects/ontologies/radlex/radlexOwl#Preferred_name&gt;  ?subClassOf.
  } LIMIT 10 OFFSET 10
  </code></pre>