write a sql query to display the name of the company that manufactures the most number of medication .incase of multiple records,display the records sorted in ascending order based on the company name?
Answers
Answered by
0
How do I write query to display the name of the company that manufactures the most number of medications?
1 ANSWER
Varun Sathyan
Varun Sathyan, Novice SQARQLer
Answered Jul 12 2016
This is a nice one to write in SPARQL. I am still somewhat of a beginner, but I couldn't resist giving it a try.
SELECT ?x (COUNT (?medication) AS ?count) WHERE {
?company ?nameIs ?x
?company ?makes ?medication
}
GROUP BY ?company ?name
You will probably have to put in actual URIs or the appropriate subj/pred/obj labels in for the variables. I just tried to make it easier to understand (for myself as well).
Hope this helps!
1 ANSWER
Varun Sathyan
Varun Sathyan, Novice SQARQLer
Answered Jul 12 2016
This is a nice one to write in SPARQL. I am still somewhat of a beginner, but I couldn't resist giving it a try.
SELECT ?x (COUNT (?medication) AS ?count) WHERE {
?company ?nameIs ?x
?company ?makes ?medication
}
GROUP BY ?company ?name
You will probably have to put in actual URIs or the appropriate subj/pred/obj labels in for the variables. I just tried to make it easier to understand (for myself as well).
Hope this helps!
Similar questions
Math,
8 months ago
Social Sciences,
8 months ago
English,
8 months ago
Physics,
1 year ago
English,
1 year ago