📌  相关文章
📜  最小日期和最大日期之间的区别 sql 代码示例

📅  最后修改于: 2022-03-11 15:05:33.290000             🧑  作者: Mango

代码示例1
SELECT
    T.location,
    Maxv.Amount - Minv.Amount as difference
FROM
(
    SELECT
       location,
       MIN(date) MinDate,
       MAX(date) MaxDate
    FROM
      Tbl A 
    GROUP BY
      location
) T INNER JOIN 
Tbl Minv ON T.MinDate = Minv.date AND T.location = Minv.location INNER JOIN 
Tbl Maxv ON T.MaxDate= Maxv.date AND T.location = Maxv.location