Skip to content

Instantly share code, notes, and snippets.

@selenamarie
Forked from danielsmith-eu/gist:8291794
Last active January 2, 2016 10:39
Show Gist options
  • Save selenamarie/8291809 to your computer and use it in GitHub Desktop.
Save selenamarie/8291809 to your computer and use it in GitHub Desktop.
WITH j_1 AS (
SELECT subject
FROM wb_v_latest_triples a
WHERE
a.predicate = 'type' AND a.obj_value = 'http://indx.ecs.soton.ac.uk/ontology/root-box/#server'
),
WITH j_2 AS (
SELECT subject
FROM wb_v_latest_triples a
WHERE
a.predicate = 'box'
)
SELECT DISTINCT
j.triple_order,
j.subject,
j.predicate,
j.obj_value,
j.obj_type,
j.obj_lang,
j.obj_datatype
FROM wb_v_latest_triples as j
JOIN j_1 USING subject
JOIN j_2 USING subject
JOIN wb_v_latest_triples AS j_3 ON (j.subject = j_3.subject)
WHERE
j_2.obj_value = j_3.subject -- concerned about the j_2.obj_value = j_3.subject ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment