MySQL: Doppelte Zahlen aufsteigend sortieren
P粉763748806
2023-07-25 12:41:47
<p>我有一个表格,看起来像这样:</p>
<table class="s-table">
<thead>
<tr>
<th>id</th>
<th>values</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>1</td>
</tr>
<tr>
<td>2</td>
<td>1</td>
</tr>
<tr>
<td>3</td>
<td>1</td>
</tr>
<tr>
<td>4</td>
<td>2</td>
</tr>
<tr>
<td>5</td>
<td>2</td>
</tr>
<tr>
<td>6</td>
<td>2</td>
</tr>
</tbody>
</table>
<p>
<table class="s-table">
<thead>
<tr>
<th>id</th>
<th>values</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>1</td>
</tr>
<tr>
<td>4</td>
<td>2</td>
</tr>
<tr>
<td>2</td>
<td>1</td>
</tr>
<tr>
<td>5</td>
<td>2</td>
</tr>
<tr>
<td>3</td>
<td>1</td>
</tr>
<tr>
<td>6</td>
<td>2</td>
</tr>
</tbody>
</table>
<p>
在ORDER BY子句中使用ROW_NUMBER()窗口函数:
可以看看这个 demo.