USP_DATALIST_MEMBERSHIPPROGRAM_SALESBYDATE

Returns data about membership sales for a given membership program by date.

Parameters

Parameter Parameter Type Mode Description
@CONTEXTID uniqueidentifier IN Input parameter indicating the context ID for the data list.

Definition

Copy


CREATE procedure dbo.USP_DATALIST_MEMBERSHIPPROGRAM_SALESBYDATE
(
  @CONTEXTID uniqueidentifier
)
as
  set nocount on;

  select
    count(MS.ID) QUANTITY,
    --The "GETEARLIESTTIME" date function has been inlined here for performance (the part with "cast(@DATE as date)")...

    cast(cast(MS.JOINDATE as date) as datetime) JOINDATE
  from dbo.MEMBERSHIP MS
  inner join dbo.MEMBERSHIPPROGRAM MP on MS.MEMBERSHIPPROGRAMID = MP.ID
  where MP.ID = @CONTEXTID and MS.STATUSCODE = 0
  group by cast(cast(MS.JOINDATE as date) as datetime)
  order by cast(cast(MS.JOINDATE as date) as datetime);

  return 0;