1SELECT
2 T.location,
3 Maxv.Amount - Minv.Amount as difference
4FROM
5(
6 SELECT
7 location,
8 MIN(date) MinDate,
9 MAX(date) MaxDate
10 FROM
11 Tbl A
12 GROUP BY
13 location
14) T INNER JOIN
15Tbl Minv ON T.MinDate = Minv.date AND T.location = Minv.location INNER JOIN
16Tbl Maxv ON T.MaxDate= Maxv.date AND T.location = Maxv.location
17