1 | 18.07 | 0mysql query sorting with different priority
<p>i´ve been hitting rock bottom recently.</p>

<p>What i´m currently trying to do is "sorting" a selection of database entries by date and if the date has passed and value X has not changed then append it ontop of the list and if the value has changed at bottom.</p>

<p>Maybe its a bit better to make some sort of graphic explaining my problem.</p>

<pre><code>Entry | "date" | X
1      | 10.07  | 0
1      | 11.07  | 1
1      | 12.07  | 1
1      | 13.07  | 1
1      | 14.07  | 1
1      | 15.07  | 1
1      | 16.07  | 1
1      | 17.07  | 1
1      | 18.07  | 0
1      | 19.07  | 1
</code></pre>

<p>This should transform to </p>

<pre><code>Entry | "date" | X
1      | 19.07  | 1
1      | 17.07  | 1
1      | 16.07  | 1
1      | 15.07  | 1
1      | 14.07  | 1
1      | 13.07  | 1
1      | 12.07  | 1
1      | 11.07  | 1
1      | 18.07  | 0
1      | 10.07  | 0
</code></pre>

<p>Is that even possible to do with "pure" mysql ?
I´ve been trying to get it sort of working by "sorting" by date, but thats not what i wanted to accomplish in the end.</p>

<pre><code>SELECT * FROM table_entries ORDER BY start_date ASC LIMIT 25
</code></pre>

<p>Have a great day</p>