CREATE table #yourtable ([Id] int, [Type] int) ; INSERT ...


Please login or register to vote for this query.

(click on this box to dismiss)

Motor Vehicle Maintenance and Repair Meta

Q&A about the site for mechanics and DIY enthusiast owners of cars, trucks, and motorcycles

CREATE table #yourtable
    ([Id] int, [Type] int)
INSERT INTO #yourtable
    ([Id], [Type])
    (1, 1),
    (2, 2),
    (3, 1),
    (4, 2),
    (5, 3)

select SUM(CASE WHEN [Type] = 1 THEN 1 ELSE 0 END)
FROM #yourtable

Enter Parameters

Switch to main site
loading Hold tight while we fetch your results