How to count more than one time with different conditions? Having a table like this:



I want to get a result like this:



Something like: 

SELECT ParentId, COUNT(SomeValue = 1) [CountMin], COUNT(SomeValue &gt; 1) [CountRest]
FROM MyTable
GROUP BY ParentId
You can use SUM(CASE...)

SELECT
    ParentID,
    SUM(CASE WHEN SomeValue = 1 THEN 1 ELSE 0 END) AS CountMin,
    SUM(CASE WHEN SomeValue &lt;&gt; 1 THEN 1 ELSE 0 END) AS CountRest
FROM
    MyTable
WHERE
    ParentID = 123;