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.
13 lines
327 B
13 lines
327 B
|
|
ALTER FUNCTION [dbo].[FNA_GET_AVAILABLE_BALANCE_POINTS](@CustomerId BIGINT)
|
|
RETURNS MONEY
|
|
AS
|
|
BEGIN
|
|
DECLARE @BALANCE MONEY
|
|
|
|
SELECT @BALANCE = ISNULL(SUM(CASE WHEN tranType = 'CR' THEN amount ELSE -1 * amount END), 0)
|
|
FROM Customer_Promotion CP(NOLOCK)
|
|
WHERE sourceCustomerId = @CustomerId
|
|
|
|
RETURN ISNULL(@BALANCE, 0)
|
|
END
|