Computer Science, asked by pragathivijayan28, 1 year ago

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 Hacket
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!
Similar questions