I am trying to figure how to query in MSSQL. What I am trying to query is how many tickets each employee submitted (in the database the reference is submitter_id
in the dbo.Tickets table) In this column is the associates number. I have another table called dbo.Users that has an id
which will match the submitter_id
from the Tickets table. I am trying to figure how I can create a count to see how many tickets were submitted in a certain date range (showing the users name
and the count). Any help with this would be greatly appreciated. (I cant figure out how to do the count* part)
SELECT Tickets.submitter_id, Users.Name, Tickets.created_at
FROM Tickets
INNER JOIN Users ON Tickets.submitter_id=Users.id;
Also tried:
select
u.Id,
u.Name,
t.created_at,
t.submitter_id,
COUNT(*) as numberOfTickets
from Users as u
join Tickets as t on t.submitter_id = u.Id
group by u.Id, u.Name, t.submitter_id
where t.created_at between '2017/11/01' and '2018/08/23'