Skip to content

Instantly share code, notes, and snippets.

@e-jigsaw
Created September 23, 2022 08:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save e-jigsaw/c9aa32f47f8fb35a5cead37283272f5c to your computer and use it in GitHub Desktop.
Save e-jigsaw/c9aa32f47f8fb35a5cead37283272f5c to your computer and use it in GitHub Desktop.
create function latest_articles(offset_arg int, limit_arg int) returns table(id text, title text, created timestamp, image text) as $$
select pages.id, pages.title, pages.created, pages.image
from pages, articles
where articles.page_id = pages.id
order by pages.created desc
offset offset_arg
limit limit_arg;
$$ stable language sql;
@e-jigsaw
Copy link
Author

select id, title, created from latest_articles(0, 20)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment