-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathorder-by.html
More file actions
47 lines (37 loc) · 2.18 KB
/
order-by.html
File metadata and controls
47 lines (37 loc) · 2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<!-- SECCIÓN ORDER BY -->
<div id="order-by-section">
<div id="adsense-container" style="width: 350px; position: absolute; left: 0px;"></div>
<div class="inner-modal">
<div class="inner" style="padding: 0px;">
<h1>SQL ORDER BY Keyword</h1>
<p>The ORDER BY keyword is used to sort the result-set in ascending or descending order.</p>
<p>The ORDER BY keyword sorts the records in ascending order by default. To sort the records in descending
order, use the DESC keyword.</p>
<h2>ORDER BY Syntax</h2>
<pre><code class="language-sql">SELECT column1, column2, ...
FROM table_name
ORDER BY column1, column2, ... ASC|DESC;</code></pre>
<h2>ORDER BY Example</h2>
<p>The following SQL statement selects all patients from the "patients" table, sorted by the "first_name"
column:</p>
<pre><code class="language-sql">SELECT * FROM patients
ORDER BY first_name;</code></pre>
<h2>ORDER BY DESC Example</h2>
<p>The following SQL statement selects all patients from the "patients" table, sorted DESCENDING by the
"first_name" column:</p>
<pre><code class="language-sql">SELECT * FROM patients
ORDER BY first_name DESC;</code></pre>
<h2>ORDER BY Several Columns Example</h2>
<p>The following SQL statement selects all patients from the "patients" table, sorted by the "first_name"
and the "last_name" column. This means that it orders by first_name, but if some rows have the same
first_name, it orders them by last_name:</p>
<pre><code class="language-sql">SELECT * FROM patients
ORDER BY first_name, last_name;</code></pre>
<h2>ORDER BY Several Columns Example 2</h2>
<p>The following SQL statement selects all patients from the "patients" table, sorted ascending by the
"first_name" and descending by the "last_name" column:</p>
<pre><code class="language-sql">SELECT * FROM patients
ORDER BY first_name ASC, last_name DESC;</code></pre>
</div>
</div>
</div>