Virtuoso Open-Source Edition

  • Topic
  • Discussion
  • VOS.VirtTipsAndTricksGuideSPARQLMINUS(Last) -- DAVWikiAdmin? , 2017-06-13 05:43:22 Edit WebDAV System Administrator 2017-06-13 05:43:22

    How Do I use MINUS in a SPARQL query?

    Virtuoso supports the MINUS function of SPARQL 1.1, as shown below --

    SQL> SPARQL 
    SELECT COUNT(*) 
    WHERE 
      { 
        { ?s ?p "Novosibirsk" } MINUS { ?s ?p "???????????" }
      }
    
    callret-0
    INTEGER
     313
    No. of rows in result: 1 
    

    View the results of the query execution on the LOD instance.

    This query is equivalent to the following query, also conforming to SPARQL 1.1 --

    SQL> SPARQL 
    SELECT COUNT(*) 
    WHERE 
      {
        ?s ?p "Novosibirsk"  FILTER NOT EXISTS { ?s ?p "???????????" } 
      }
    
    callret-0
    INTEGER
    313
    No. of rows in result: 1 
    

    View the results of the query execution on the LOD instance.

    Related