UFN_FAFMONTHLYCOMMUNICATIONS

Get monthly communication totals

Return

Return Type
table

Parameters

Parameter Parameter Type Mode Description
@EVENTID uniqueidentifier IN
@CLIENTUSERSID int IN

Definition

Copy


create function dbo.UFN_FAFMONTHLYCOMMUNICATIONS
(
  @EVENTID AS uniqueidentifier
    ,@CLIENTUSERSID    AS INT = null

)
RETURNS TABLE
AS
RETURN
  WITH
  [MONTHGROUP]
  AS
  (
  select dateadd(month, datediff(month, 0, DATESENT),0) as mdate ,COUNT(*) as no_sent
  FROM dbo.FAFCOMMUNICATIONSLOG WITH (NOLOCK)
  WHERE EVENTID = @EVENTID AND CLIENTUSERSID = ISNULL(@CLIENTUSERSID,CLIENTUSERSID)
  group by dateadd(month, datediff(month, 0, DATESENT),0)
  )
  SELECT RIGHT(CONVERT(CHAR(11),mdate,106),8) as MONTHNAME, no_sent as TOTAL from MONTHGROUP;