UFN_MEMBERSHIP_GETTODAYSMEMBERSHIPREVENUE
Returns the total revenue from memberships sold today.
Return
Return Type |
---|
money |
Definition
Copy
create function dbo.UFN_MEMBERSHIP_GETTODAYSMEMBERSHIPREVENUE()
returns money
with execute as caller
as begin
declare @FROMDATE datetime = (select dbo.UFN_DATE_GETEARLIESTTIME(getdate()))
declare @TODATE datetime = (select dbo.UFN_DATE_GETLATESTTIME(getdate()))
return(
select
sum(SOI.TOTAL) TOTAL
from dbo.SALESORDERITEM SOI
inner join dbo.SALESORDERITEMMEMBERSHIP SOIM on SOI.ID = SOIM.ID
inner join dbo.SALESORDER SO on SO.ID = SOI.SALESORDERID
inner join dbo.MEMBERSHIP MS on SOIM.MEMBERSHIPID = MS.ID
where MS.STATUSCODE <> 1
and SO.TRANSACTIONDATE between @FROMDATE and @TODATE
)
end