KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have this function in PostgreSQL, but I don't know how to return the result of the query: CREATE OR REPLACE FUNCTION wordFrequency(maxTokens INTEGER) RETURNS SETOF RECORD AS $$ BEGIN SELECT text, count(*), 100 / maxTokens * count(*) FROM ( SELECT text FROM token WHERE chartype = 'ALPHABETIC' LIMIT maxTokens ) AS tokens GROUP BY text ORDER BY count DESC END $$ LANGUAGE plpgsql; But I don't know how to return the result of the query inside the PostgreSQL function. I found that the return type should be SETOF RECORD , right? But the return command is not right. What is the right way to do this?
Tags (comma-separated)
Save Edits
Cancel