Skip to content
Discussion options

You must be logged in to vote

Answering my own question.

I was having "as users" in the first select which was conflicting and secondly, the column in the comments_row needed to be quoted within ".."

Create or replace FUNCTION users_with_top_comments(comments_row comments)
RETURNS SETOF users AS $$
select distinct(users.id) as id, users.username, users."firebaseId",count("comments".id) as plusOneRankMain,
---> users."plusOneRankComments", users."profilePicture", users."createdOn" from users as users
inner join "public"."comments" as com on com."userId" = users.id
---> where users.id = comments_row.userId
group by users.id
$$ LANGUAGE sql STABLE;

CREATE OR REPLACE FUNCTION public.users_with_top_comments(comments_row co…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by accilies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant