Hi!
I have table using function I want get result after multiple amount.
Now I get only one result. I want get list result by using function.
Table: acct
Id |
Account |
Amount |
1 |
10000001 |
500 |
2 |
10000002 |
600 |
3 |
10000003 |
200 |
4 |
10000004 |
300 |
5 |
10000005 |
400 |
6 |
10000006 |
800 |
7 |
10000007 |
100 |
8 |
10000008 |
150 |
9 |
10000009 |
650 |
10 |
10000010 |
450 |
11 |
10000011 |
680 |
12 |
10000012 |
950 |
13 |
10000013 |
590 |
14 |
10000014 |
700 |
15 |
10000015 |
780 |
16 |
10000016 |
870 |
17 |
10000017 |
880 |
18 |
10000018 |
876 |
19 |
10000019 |
900 |
20 |
10000020 |
966 |
CREATE FUNCTION multiple (
@acct char(10)
)
RETURNS Decimal(5,2) AS
BEGIN
DECLARE @result Decimal(5,2);
SET @result = (select round((amount / 100),2) * 0.03 from acct where account = @acct)
RETURN @result
END;
declare @acct int, @counter int, @irr decimal(5,2)
set @counter = 0
while(@counter <= (select count(*) from acct))
begin
set @acct = (SELECT Account FROM (SELECT ROW_NUMBER() OVER(ORDER BY (SELECT 0)) SiNo, Account FROM acct) t WHERE t.SiNo = @Counter)
set @irr = dbo.multiple(@acct)--(SELECT Account FROM (SELECT ROW_NUMBER() OVER(ORDER BY (SELECT 0)) SiNo, Account FROM acct) t WHERE t.SiNo = @Counter)
begin
print @irr --dbo.multiple(@acct)
end
set @counter = @counter + 1
end
I got 0.15 now. Why I can;t get list result?