You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

18 lines
582 B

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE FUNCTION [dbo].[FNA_GET_REWARD_POINTS]()
RETURNS @list TABLE (totalPoints INT, RegPoint INT, TranPoint INT)
AS
BEGIN
INSERT INTO @list (totalPoints, RegPoint, TranPoint)
SELECT
SUM(CASE WHEN PromotionType IN ('REGISTRATION', 'TRANSACTION') THEN Points ELSE 0 END) AS totalPoints,
SUM(CASE WHEN PromotionType = 'REGISTRATION' THEN Points ELSE 0 END) AS RegPoint,
SUM(CASE WHEN PromotionType = 'TRANSACTION' THEN Points ELSE 0 END) AS TranPoint
FROM TBL_PROMOTION_SETUP;
RETURN;
END