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

  1. SET ANSI_NULLS ON
  2. GO
  3. SET QUOTED_IDENTIFIER ON
  4. GO
  5. CREATE FUNCTION [dbo].[FNA_GET_REWARD_POINTS]()
  6. RETURNS @list TABLE (totalPoints INT, RegPoint INT, TranPoint INT)
  7. AS
  8. BEGIN
  9. INSERT INTO @list (totalPoints, RegPoint, TranPoint)
  10. SELECT
  11. SUM(CASE WHEN PromotionType IN ('REGISTRATION', 'TRANSACTION') THEN Points ELSE 0 END) AS totalPoints,
  12. SUM(CASE WHEN PromotionType = 'REGISTRATION' THEN Points ELSE 0 END) AS RegPoint,
  13. SUM(CASE WHEN PromotionType = 'TRANSACTION' THEN Points ELSE 0 END) AS TranPoint
  14. FROM TBL_PROMOTION_SETUP;
  15. RETURN;
  16. END