I assume the Table name Person
Code:
select First.Name as FirstPerson,
Second.Name as SecondPerson,
(First.Age - Second.Age) as AgeDifference
from Person as First,
Person as Second
where First.Id < Second.Id
i made it so u don t get jim | mary | 5 and mary | jim | -5 ... if u want that, use <> instead of <
use this query if u hate to see the negative age differences
Code:
select First.Name as FirstPerson,
Second.Name as SecondPerson,
(First.Age - Second.Age) as AgeDifference
from Person as First,
Person as Second
where First.Age > Second.Age Or (First.Age = Second.Age AND First.Id < Second.Id)