简体   繁体   中英

Sparql operation on union of two queries

I have two sparql querys , simplifying my problem :

query 1:

 select ?letter ?number 

-> results ({a1}{b2}{d4})

.... query 2:

 select ?anotherletter ?anotherNumber 

-> results ({b2}{c3})

How can i join the 2 querys to obtain the sum of the second column, maybe same values of a one lista couldnt be in the second. The result of the query has to be

{a,1}{b,4}{c,3}{d,4}

Is there a propper way to do that?

The solution that gives @UninformedUser worked:

select ?letter (sum(?number) as ?cnt) {  {QUERY1} UNION {QUERY2} } group by ?letter

and yes, the variables should be the same in both UNION parts. – UninformedUser

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM