title: Rails Postgresql sort by random
body: <p>I am trying to pull out rows from a postgres database, I can pull them out desc but when I try random I get a Syntax error near random.</p>
  
  <p><strong>Error</strong> </p>
  
  <pre><code>PG::Error: ERROR:  syntax error at or near "rand"
  LINE 1: ...  "hashtags".* FROM "hashtags"  ORDER BY tweet_id rand LIMIT...
                                                               ^
  : SELECT  "hashtags".* FROM "hashtags"  ORDER BY tweet_id rand LIMIT 4
  </code></pre>
  
  <p><strong>Code to pull it out</strong></p>
  
  <pre><code>&lt;div id="hashtags"&gt;
  &lt;% Hashtag.order("tweet_id desc").limit(4).each do |hashtag| %&gt;
     &lt;blockquote&gt;&lt;%= hashtag.content %&gt;&lt;/blockquote&gt;
     &lt;div class="from"&gt;&amp;mdash; @&lt;%= hashtag.screen_name %&gt;&lt;/div&gt;
   &lt;% end %&gt;
  &lt;/div&gt;
  </code></pre>