Write a SQL query to find all nodes whose degree is below the average degree of
ID: 3784279 • Letter: W
Question
Write a SQL query to find all nodes whose degree is below the average degree of the vertices in the graph. The degree of a vertex is the number of edges incident on the vertex (i.e., starting from or ending in that vertex). For example, the degree of vertex 6 is 5.
A graph G (V, E) is defined by a setV of vertices, indicated by circles in the picture, and a set E of edges connecting the vertices. In the graph above, V {1, 7 and E (1,2), (1,4), (4,6), (2,3), (2,6), (6,5), (6,7), (5,3) (3,1), (3,6).Explanation / Answer
Let the corresponding table is Graph and it has degree column. The rquired SQL query will be:
Select degree from Graph
Where degree > (Select AVG(degree) from Graph);
Hope it helps.
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.