How to do mathematical operations on one field with different WHERE filter

for example, temperature data from two different locations stored in one measurement, like

time                temperature               location
----                ----                              ----
1                     15                                 A
2                     20                                 B
3                     17                                 A
4                     18                                 B

How to calculate the difference between temperatures at A and B with querying?
i.e. expecting something like “SELECT a.temperature - b.temperature FROM measurement WHERE location = ‘A’ as a WHERE location = ‘B’ as b”