'Get properties from a group of items in with SPARQL

I need to use the SPARQL query service from Wikidata.

What I need to retrieve is a list of all properties that items which are instance of (P31) disease (Q12136) have

I'm having some trouble understanding how to nest two queries

With this Query we have all the items which are instance of disease:

SELECT ?item WHERE { ?item wdt:P31 wd:Q12136 . }

Then this is the list of properties, but instead of searching in the entire site I have to search in the subgroup obtained in the previous sentence

SELECT DISTINCT ?property ?propertyLabel WHERE { ?property a wikibase:Property . SERVICE wikibase:label { bd:serviceParam wikibase:language "en" } } ORDER BY ?propertyLabel

What is the correct way to nest both queries? Also, can you retrieve the type of the properties, too?

Thanks.



Sources

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

Source: Stack Overflow

Solution Source