【问题标题】:SQL: list of points to rectangleSQL:点到矩形的列表
【发布时间】:2010-08-01 19:07:00
【问题描述】:

我有两张桌子:

regions <id>
points <region_id, x, y>

假设每个区域正好有 4 个点,这些点描述了一个矩形——是否有一个 SQL 查询可以让我看到这个视图:

rectangular_regions <region_id, x1, y1, x2, y2>

?

【问题讨论】:

    标签: sql points regions


    【解决方案1】:
    SELECT region_id, MIN(x) AS x1, MIN(y) AS y1, MAX(x) AS x2, MAX(y) AS y2 
    FROM points 
    GROUP BY region_id.
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-11-20
      • 1970-01-01
      • 2014-06-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多