Jump to content

MySql query

I have to make a query that I cannot, for the life of me, figure out. I have to return alliances that have more population than an average alliance has. But the thing is I have to calculate the average based on the number of population of an alliance, not individual players. In the spoiler window, there is a data model of the database.

Spoiler

image.png.39013f8ff786ebd6eb4d7833559ba428.png

Spoiler

SELECT a.aid, alliance, SUM(population) AS population FROM igralec i
INNER JOIN naselje n ON n.pid = i.pid
INNER JOIN aliansa a ON a.aid = i.aid
GROUP BY a.aid, alliance
ORDER BY populacija DESC;

This is how I get the number of people living in the alliances

 

Oh and sorry that some text in the tables is in Slovene and not English.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×