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.

12 lines
327 B

  1. ALTER FUNCTION [dbo].[FNA_GET_AVAILABLE_BALANCE_POINTS](@CustomerId BIGINT)
  2. RETURNS MONEY
  3. AS
  4. BEGIN
  5. DECLARE @BALANCE MONEY
  6. SELECT @BALANCE = ISNULL(SUM(CASE WHEN tranType = 'CR' THEN amount ELSE -1 * amount END), 0)
  7. FROM Customer_Promotion CP(NOLOCK)
  8. WHERE sourceCustomerId = @CustomerId
  9. RETURN ISNULL(@BALANCE, 0)
  10. END