我无法弄清楚如何在获得最大关联和最小关联的一个查询中获得这些查询?

时间:2019-03-25 17:04:43

标签: mysql

      SELECT C.Name AS Country, SUM(T.Population) / C.Population AS 
      Relation
          FROM Country C LEFT OUTER JOIN City T ON C.Code =T.CountryCode
          WHERE C.Region = 'Nordic Countries'
      GROUP BY C.Name
      ORDER BY Relation DESC
      LIMIT 1;

其他查询

      SELECT C.Name AS Country, SUM(T.Population) / C.Population AS 
      Relation
          FROM Country C LEFT OUTER JOIN City T ON C.Code =T.CountryCode
          WHERE C.Region = 'Nordic Countries'
      GROUP BY C.Name
      ORDER BY Relation ASC
      LIMIT 1;

1。这些使用城市和国家/地区表的查询,我无法在同一查询中获得最大关系和最小关系的情况下进行查询。

0 个答案:

没有答案