title: Multiple counts in Sparql query
body: <p>I would like to create a Sparql query that contains two counts.</p>
  
  <p>The query should get the 'neighbours of neighbours' of A (A &rightarrow; B &rightarrow; C, where A is the start node), and should report for each C, how many paths there were from A to C, and how many "inlinks" there are to C from anywhere. The result set should be as follow:</p>
  
  <pre class="lang-none prettyprint-override"><code>C | #C |  C_INLINKS
  --------------------------
  A | 2  | 123
  B | 3  | 234
  </code></pre>
  
  <p>Where #C is the number of paths to C from starting node A.</p>
  
  <p>I can create the counts separately, but I don't know how to combine these:</p>
  
  <p><a href="http://dbpedia.org/sparql?default-graph-uri=http%3A%2F%2Fdbpedia.org&amp;query=select%20%3Fc%20count%28%3Fc%29%20as%20%3Fcountc%20WHERE%20%7B%0D%0A%20%20%20%3Chttp%3A%2F%2Fdbpedia.org%2Fresource%2FAFC_Ajax%3E%20%3Fp1%20%3Fb.%0D%0A%20%20%20%3Fb%20%3Fp2%20%3Fc.%0D%0A%20%20%20FILTER%20%28regex%28str%28%3Fc%29%2C%20%27%5Ehttp%3A%2F%2Fdbpedia.org%2Fresource%2F%27%29%29%0D%0A%7D%0D%0AGROUP%20BY%20%3Fc%0D%0AORDER%20BY%20DESC%28%3Fcountc%29%0D%0ALIMIT%20100&amp;format=text%2Fhtml&amp;timeout=30000&amp;debug=on" rel="nofollow"><strong>Count neighbours of neighbours:</strong></a></p>
  
  
  
  <pre class="lang-sql prettyprint-override"><code>select ?c count(?c) as ?countc WHERE {
     &lt;http://dbpedia.org/resource/AFC_Ajax&gt; ?p1 ?b.
     ?b ?p2 ?c.
     FILTER (regex(str(?c), '^http://dbpedia.org/resource/'))
  }
  GROUP BY ?c
  ORDER BY DESC(?countc)
  LIMIT 100
  </code></pre>
  
  <p><a href="http://dbpedia.org/sparql?default-graph-uri=http%3A%2F%2Fdbpedia.org&amp;query=select+%3Fc+count%28%3Finlink%29+as+%3Finlinks+WHERE+%7B%0D%0A+++%3Chttp%3A%2F%2Fdbpedia.org%2Fresource%2FAFC_Ajax%3E+%3Fp1+%3Fb.%0D%0A+++%3Fb+%3Fp2+%3Fc.%0D%0A+++%3Finlink+%3Fp3+%3Fc%0D%0A+++FILTER+%28regex%28str%28%3Fc%29%2C+%27%5Ehttp%3A%2F%2Fdbpedia.org%2Fresource%2F%27%29%29%0D%0A%7D%0D%0AGROUP+BY+%3Fc%0D%0AORDER+BY+DESC%28%3Finlinks%29%0D%0ALIMIT+100&amp;format=text%2Fhtml&amp;timeout=30000&amp;debug=on" rel="nofollow"><strong>Count inlinks to neighbours of neigbours</strong></a></p>
  
  <pre class="lang-sql prettyprint-override"><code>select ?c count(?inlink) as ?inlinks WHERE {
     &lt;http://dbpedia.org/resource/AFC_Ajax&gt; ?p1 ?b.
     ?b ?p2 ?c.
     ?inlink ?p3 ?c
     FILTER (regex(str(?c), '^http://dbpedia.org/resource/'))
  }
  GROUP BY ?c
  ORDER BY DESC(?inlinks)
  LIMIT 100
  </code></pre>
  
  <p>Is it possible to combine these two queries? Thank you!</p>