@prefix rr: <http://www.w3.org/ns/r2rml#> .
@prefix ex: <http://example.com/ns#> .

<#TriplesMap1>
    rr:logicalTable [ rr:tableName "EMP" ];
    rr:subjectMap [
        rr:template "http://data.example.com/employee/{EMPNO}";
    ];
	rr:predicateObjectMap [
		rr:predicate ex:department;
		rr:objectMap [
			rr:parentTriplesMap <#TriplesMap2>;
			rr:joinCondition [
				rr:child "DEPTNO";
				rr:parent "DEPTNO";
			];
		];
	].
	
<#TriplesMap2>
    rr:logicalTable <#DeptTableView>;
    rr:subjectMap [
        rr:template "http://data.example.com/department/{DEPTNO}";
    ].
	
<#DeptTableView> rr:sqlQuery """
	SELECT DEPTNO,
	       DNAME,
	       LOC,
	       (SELECT COUNT(*) FROM EMP WHERE EMP.DEPTNO=DEPT.DEPTNO) AS STAFF
	FROM DEPT
	""".