SQLTeam.com | Weblogs | Forums

Query to Count Number of Events in One Day


#1

Hello All,

I am writing to ask how I might create a SQL query to obtain a count of the number of records for each day "column1" has a value of "value1"

The output I would like to see is each row having two columns, the date and then the number of times "value1" appeared in "column1" that for that day. Any help is greatly appreciated.

Thanks in advance,
Aaron


#2

Always provide sample data

create table #AWRontheRISE(Event varchar(50), EventDate date)

insert into #AWRontheRISE
select 'A New Hope', '2017-05-01' union
select 'The Phantom Menace', '2017-05-01' union
select 'Attack of the Clones', '2017-06-01' union
select 'Revenge of the Sith', '2017-06-01'

select COUNT(*), EventDate
 from #AWRontheRISE
 group by EventDate

 select COUNT(distinct Event), EventDate
 from #AWRontheRISE
 group by EventDate

drop table #AWRontheRISE