'execute CONSTRUCT query one time with more than one result of WHERE clause

Given the below SPARQL query


CONSTRUCT {
sc_reserved:root sc_language:people [
rdf:type sc_language:borrower  ;
sc_language:works_for [
rdf:type sc_language:organization  ;
sc_language:has_organization_name [
sc_language:has_value ?01FWR5J95HZYQTGTKP88FXWBGB ]
]
 ;
sc_language:employed_as [
rdf:type sc_language:employment ]
 ;
sc_language:earns [
rdf:type sc_language:employment_income  ;
sc_language:_label "incomes"  ;
sc_language:has_income_year [
sc_language:has_value ?01FWR5J95HXQS44NEB89QXYPMP ]
 ;
sc_language:has_income_amount [
sc_language:has_value ?01FWR5J95H4WD8TAJEPGRBYXF3 ]

]
]

}
WHERE {
?01FWR5J95H8GFB7JKTZASYH2BG partner_language:reports/partner_language:employer ?01FWR5J95H1X58BRHAJ32Z2SWF .
?01FWR5J95H1X58BRHAJ32Z2SWF partner_language:name ?01FWR5J95HZYQTGTKP88FXWBGB .
?01FWR5J95H8GFB7JKTZASYH2BG partner_language:reports/partner_language:employee ?x . 
 
 ?x partner_language:earnings ?01FWR5J95HKQRQQG501RW7FSEN .
 ?01FWR5J95HKQRQQG501RW7FSEN partner_language:year ?01FWR5J95HXQS44NEB89QXYPMP .
 ?01FWR5J95HKQRQQG501RW7FSEN partner_language:total ?01FWR5J95H4WD8TAJEPGRBYXF3 .
  
 }

I receive

sc_reserved:root ns1:people [ a ns1:borrower ;
            ns1:earns [ a ns1:employment_income ;
                    ns1:_label "incomes" ;
                    ns1:has_income_amount [ ns1:has_value "2000" ] ;
                    ns1:has_income_year [ ns1:has_value "2021" ] ;

            ns1:employed_as [ a ns1:employment ] ;
            ns1:works_for [ a ns1:organization ;
                    ns1:has_organization_name [ ns1:has_value "SOME NAME" ] ] ],
        [ a ns1:borrower ;
            ns1:earns [ a ns1:employment_income ;
                    ns1:_label "incomes" ;
                    ns1:has_income_amount [ ns1:has_value "2000" ] ;
                    ns1:has_income_year [ ns1:has_value "2020" ] ;
            ns1:employed_as [ a ns1:employment ] ;
            ns1:works_for [ a ns1:organization ;
                    ns1:has_organization_name [ ns1:has_value "SOME NAME" ] ] ] .

which means the WHERE clause made the CONSTRUCT applied two times so got me two sc_language:borrower each of which has one value of the sc_language:earns

but in fact what I am looking for is one sc_language:borrower with two sc_language:earns as a result.

What should with my query to get this?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source