 <p>Something like:</p> <pre><code>SELECT col1, col2, col3 FROM ( SELECT *,1 AS SortCol FROM tbl_post WHERE paid_until &gt;= :time_stamp UNION SELECT *,2 AS SortCol FROM tbl_post WHERE paid_until &lt; :time_stamp )AS sub ORDER BY SortCol, modified DESC </code></pre>