Skip to content

Instantly share code, notes, and snippets.

@ryankinal
Created February 13, 2012 19:44
Show Gist options
  • Save ryankinal/1819511 to your computer and use it in GitHub Desktop.
Save ryankinal/1819511 to your computer and use it in GitHub Desktop.
No fours here. Dammit.
CREATE PROCEDURE spGetChatUsersFlagged
@threshold int
AS
BEGIN
SET NOCOUNT ON;
SELECT DISTINCT
Students.username,
Students.StudentID,
COUNT(flagID) AS FlagCount
FROM
Students
JOIN ChatMessages ON Students.StudentID = ChatMessages.studentID
JOIN ChatMessageFlag ON ChatMessages.messageID = ChatMessageFlag.messageID
GROUP BY
Students.UserName,
Students.StudentID
HAVING
COUNT(flagID) >= @threshold
END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment