CREATE TABLE Has_amenity (dormid INT, amenid INT)
CREATE TABLE Dorm_amenity (amenid INT, amenity_name VARCHAR)
CREATE TABLE Lives_in (stuid INT, dormid INT, room_number INT)
CREATE TABLE Student (StuID INT, LName VARCHAR, Fname VARCHAR, Age INT, Sex VARCHAR, Major INT, Advisor INT, city_code VARCHAR)
CREATE TABLE Dorm (dormid INT, dorm_name VARCHAR, student_capacity INT, gender VARCHAR)

Find the average age of students living in each dorm and the name of dorm Plot them as bar chart, rank by the bars in asc.
SELECT dorm_name, AVG(T1.Age) FROM Student AS T1 JOIN Lives_in AS T2 ON T1.stuid = T2.stuid JOIN Dorm AS T3 ON T3.dormid = T2.dormid GROUP BY T3.dorm_name ORDER BY dorm_name
SELECT "dorm_name", AVG("T1"."Age") FROM "Student" AS "T1" JOIN "Lives_in" AS "T2" ON "T1"."stuid" = "T2"."stuid" JOIN "Dorm" AS "T3" ON "T2"."dormid" = "T3"."dormid" GROUP BY "T3"."dorm_name" ORDER BY "dorm_name" NULLS FIRST