-- utilizando puros case select id,count(case when valor > 0 then valor end) as positivo,count(case when valor<0 then valor end) as negativo from nomtabla group by id --