Example SPARQL queries

SPARQL endpoint, graph IDs: id:65948b27-93be-4ace-9091-f2272525a6cd (Windows 10 installation ISO), id:b45785a7-e8bf-4428-8996-14caec7eaaed (Windows 11 installation ISO).

Clicking on any of the query titles will send it to the endpoint.

Counting the number of distinct subjects for all predicate-object pairs

SELECT ?source ?property ?object ((COUNT(DISTINCT ?item)) AS ?count)
WHERE {
  VALUES ?graph {
    id:65948b27-93be-4ace-9091-f2272525a6cd
    id:b45785a7-e8bf-4428-8996-14caec7eaaed
  }

  GRAPH ?graph {
    ?graph nfo:fileName ?source .
    ?item ?property ?object .
  }
}
GROUP BY ?source ?property ?object
HAVING (COUNT(DISTINCT ?item) > 4)
ORDER BY DESC(COUNT(DISTINCT ?item)) ASC(?source)

Producing the minimum, maximum value of properties, and average value for numeric objects of properties

SELECT ?source ?property (MIN(?value) AS ?min) (AVG(IF(isNumeric(?value),?value,"INF"^^xsd:double)) AS ?avg) (MAX(?value) AS ?max)
WHERE {
  VALUES ?graph {
    id:65948b27-93be-4ace-9091-f2272525a6cd
    id:b45785a7-e8bf-4428-8996-14caec7eaaed
  }

  GRAPH ?graph {
    ?graph nfo:fileName ?source .
    ?item ?property ?value .
  }
}
ORDER BY ?property ?source

Counting the number of distinct objects for each property

SELECT ?source ?property ((COUNT(DISTINCT ?object)) AS ?count)
WHERE {
  VALUES ?graph {
    id:65948b27-93be-4ace-9091-f2272525a6cd
    id:b45785a7-e8bf-4428-8996-14caec7eaaed
  }

  GRAPH ?graph {
    ?graph nfo:fileName ?source .
    [] ?property ?object .
  }
}
GROUP BY ?source ?property
ORDER BY DESC(COUNT(DISTINCT ?object)) ASC(?source)

Listing the objects of properties nie:interpretedAs and schema:encodingFormat that are missing from either graphs

SELECT ?source ?property ?object
WHERE {
  VALUES (?graph_a ?graph_b) {
    (id:65948b27-93be-4ace-9091-f2272525a6cd id:b45785a7-e8bf-4428-8996-14caec7eaaed)
    (id:b45785a7-e8bf-4428-8996-14caec7eaaed id:65948b27-93be-4ace-9091-f2272525a6cd)
  }
  GRAPH ?graph_a {
    ?graph_a nfo:fileName ?source .
    VALUES ?property {
      nie:interpretedAs
      schema:encodingFormat
    }
    [] ?property ?object .
    FILTER NOT EXISTS {
      GRAPH ?graph_b {
        [] ?property ?object .
      }
    }
  }
}
ORDER BY ?property ?object

Listing the files with textual content whose both path and content is missing from the other graph

SELECT ?source ?file
WHERE {
  VALUES (?graph_a ?graph_b) {
    (id:65948b27-93be-4ace-9091-f2272525a6cd id:b45785a7-e8bf-4428-8996-14caec7eaaed)
  }
  GRAPH ?graph_a {
    ?graph_a nfo:fileName ?source .
    ?file nie:interpretedAs ?object .
    ?file at:pathObject ?path .
    ?object a cnt:ContentAsText.
    FILTER NOT EXISTS {
      GRAPH ?graph_b {
        { [] nie:interpretedAs ?object . } UNION { [] at:pathObject ?path . }
      }
    }
  }
}
ORDER BY ?file

Identifying applications not made by Microsoft

SELECT DISTINCT ?exe ?creator
WHERE {
  VALUES ?graph {
    id:65948b27-93be-4ace-9091-f2272525a6cd
    id:b45785a7-e8bf-4428-8996-14caec7eaaed
  }
  GRAPH ?graph {
    ?exe a schema:SoftwareApplication .
    FILTER NOT EXISTS {
      VALUES ?microsoft {
        "Microsoft Corporation"@en-us
        "Microsoft Corporation"@en-gb
        "Microsoft Corporation"
      }
      ?exe dcterms:creator ?microsoft .
    }
    OPTIONAL {
      ?exe dcterms:creator ?creator .
    }
  }
}

Counting the total number and size of duplicated files

SELECT ?source (SUM(?count) AS ?total_count) (SUM(?size) AS ?size)
WHERE {
  {
    SELECT ?source ((COUNT(?file)-1) AS ?count) ((SUM(?size)-SAMPLE(?size)) AS ?size)
    WHERE {
      VALUES ?graph {
        id:65948b27-93be-4ace-9091-f2272525a6cd
        id:b45785a7-e8bf-4428-8996-14caec7eaaed
      }

      GRAPH ?graph {
        ?graph nfo:fileName ?source .
        ?file nie:interpretedAs ?content .
        { ?content a cnt:ContentAsText . } UNION { ?content a cnt:ContentAsBase64 . }
        ?file nfo:fileSize ?size .
      }
    }
    GROUP BY ?source ?content
    HAVING (COUNT(?file) > 1)
  }
}
GROUP BY ?source

Retrieving all pieces of content with multiple formats

SELECT ?source ?content
WHERE {
  VALUES ?graph {
    id:65948b27-93be-4ace-9091-f2272525a6cd
    id:b45785a7-e8bf-4428-8996-14caec7eaaed
  }
  GRAPH ?graph {
    ?graph nfo:fileName ?source .
    ?content dcterms:hasFormat ?format .
    FILTER NOT EXISTS {
      # Ignore certificates, interpreted from executables
      ?format a cert:X509Certificate .
    }
  }
}
GROUP BY ?source ?content
HAVING (COUNT(?format) > 1)
ORDER BY DESC(COUNT(?format)) ASC(?source)