Этот запрос должен работать с большинством платформ баз данных:
select sum(case when val1 > val2 then 1 end) as GreaterThanCount,
sum(case when val1 < val2 then 1 end) as LessThanCount
from MyTable
Чтобы отобразить суммы в отдельных строках, вы можете выполнить:
select case when val1 > val2 then 'GreaterThan' else 'LessThan' end as Type,
count(*) as Count
from MyTable
group by case when val1 > val2 then 'GreaterThan' else 'LessThan' end