I use the below query,but throws an error:
CREATE FUNCTION getCustomerPaymentFunc (@customerCode bigint )
RETURNS bigint AS BEGIN
RETURN
( if(select coun from getCustomerPaymentCount (@customerCode))=0)
select 0 as price
else
(select SUM(price) as code
from PaymentLog
where customerCode=@customerCode)
) END
I Use below Two but says:
select statement included within a function cannot return data to client
CREATE FUNCTION getCustomerPaymentFunc (@customerCode bigint )
RETURNS bigint AS BEGIN
RETURN
(
SELECT CASE WHEN (select coun from getCustomerPaymentCount(@customerCode))=0
THEN 0 ELSE 1 END as
(select SUM(price) as code from PaymentLog
where customerCode=@customerCode)
) END