Skip to content

Instantly share code, notes, and snippets.

@lettergram
Last active May 14, 2019 04:00

Revisions

  1. lettergram revised this gist May 14, 2019. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion postgresql_subquery.sql
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,4 @@
    /**
    * Table Structure:
    * comments
    * author
    * comment_text
  2. lettergram revised this gist May 14, 2019. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion postgresql_subquery.sql
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,6 @@
    * comment_text
    * created_at
    **/

    SELECT author, created_at FROM
    (SELECT * FROM comments WHERE (created_at >= NOW() - interval '6 month')
    ORDER BY created_at DESC LIMIT 100) subquery
  3. lettergram revised this gist May 14, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion postgresql_subquery.sql
    Original file line number Diff line number Diff line change
    @@ -9,4 +9,4 @@
    SELECT author, created_at FROM
    (SELECT * FROM comments WHERE (created_at >= NOW() - interval '6 month')
    ORDER BY created_at DESC LIMIT 100) subquery
    ORDER BY author ASC NULLS LAST LIMIT 10;
    ORDER BY author ASC;
  4. lettergram revised this gist May 14, 2019. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion postgresql_subquery.sql
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,5 @@
    /**
    * Table Structure:
    *
    * comments
    * author
    * comment_text
  5. lettergram revised this gist May 14, 2019. 1 changed file with 9 additions and 0 deletions.
    9 changes: 9 additions & 0 deletions postgresql_subquery.sql
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,12 @@
    /**
    * Table Structure:
    *
    * comments
    * author
    * comment_text
    * created_at
    **/

    SELECT author, created_at FROM
    (SELECT * FROM comments WHERE (created_at >= NOW() - interval '6 month')
    ORDER BY created_at DESC LIMIT 100) subquery
  6. lettergram renamed this gist May 14, 2019. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  7. lettergram created this gist May 14, 2019.
    4 changes: 4 additions & 0 deletions postgresql_temporary_query.sql
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,4 @@
    SELECT author, created_at FROM
    (SELECT * FROM comments WHERE (created_at >= NOW() - interval '6 month')
    ORDER BY created_at DESC LIMIT 100) subquery
    ORDER BY author ASC NULLS LAST LIMIT 10;