Quantcast
Channel: User Schwern - Stack Overflow
Viewing all articles
Browse latest Browse all 581

Answer by Schwern for User defined function only returns first value in column

$
0
0

From what you described, seems like the function should only be formatting a value.

create or replace function format_as_money(m float) returns text    language sql    immutable    returns null on null input    return to_char(1, 'L') || m;

Note, I don't know the specifics of your table or your assignment, but you should be able to adjust from here. See the Examples section of the create function docs.

Then use that in a select by passing the amount column in.

select  title,  format_as_money(amount) as formatted_amountfrom detail_reportorder by title

Viewing all articles
Browse latest Browse all 581

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>