Im trying to count how many rows in a table by month and year. Then getting the rows to examine for that time period but my scripts are way out in numbers First - get all rows split into months
SELECT COUNT(*)
FROM EmailSends
WHERE YEAR(CreateDate) = '2020'
GROUP BY MONTH(CreateDate)
gives me an output of
(No column name)
24967 <-January
37251
13897
7498
12052
79943
26146
4340
4961
75797
17340
17653
then I run the below expecting 24967 rows but get 79,943 but the date range is good from the results. (Jan 1-31 2020)
SELECT EmailID,CreateDate,Subject
FROM Emailsends
WHERE MONTH (createdate) = '1' and YEAR(CreateDate) = '2020'
GROUP BY Emailsends.CreateDate,Emailsends.EmailID ,MONTH(CreateDate),Emailsends.Subject
.
select * from Emailsends where CreateDate between '2020-01-01 00:00:00.001' and '2020-02-01 00:00:00.001'
also returns 79943
Can you help? - unsure what I'm doing wrong. - Looks like the count script isn't playing or there's something else being counted that the count script isn't.