Skip to content
Advertisement

How to count 2 rows between 2 numbers in the same column

SELECT (COUNT (*))
FROM dbo.DIM_Calendar
WHERE (IdCalendar = 20190916  AND IdCalendar = 20191031)

The IDCalendar its an INT type, I would like to know the count between those 2 IdCalendars.

Advertisement

Answer

Maybe you’re missing information. But what I understand what you want is as simple as use >= and <=

 SELECT (COUNT (*))
 FROM dbo.DIM_Calendar
 WHERE (IdCalendar >= 20190916  AND IdCalendar <= 20191031)
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement