-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlag.html
More file actions
33 lines (27 loc) · 1.37 KB
/
lag.html
File metadata and controls
33 lines (27 loc) · 1.37 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
<!-- SECCIÓN LAG WINDOW FUNCTION -->
<div id="lag-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 LAG() Window Function</h1>
<p>The <strong>LAG()</strong> function returns the record offset by the specified amount.</p>
<h2>Syntax</h2>
<pre><code class="language-sql">LAG(expression [, offset])</code></pre>
<h2>Parameter Values</h2>
<ul>
<li><strong>expression</strong>: Required. The value to be returned based on the specified offset. Must
be a scalar value; cannot be an analytic function.</li>
<li><strong>offset</strong>: Optional. Number of rows back from the current row. Default is 1. Must be
positive; cannot be negative or an analytic function.</li>
</ul>
<h2>LAG() Example</h2>
<p>The following SQL statement displays each patient's <strong>first_name</strong> along with the
<strong>first_name</strong> of the previous patient:</p>
<pre><code class="language-sql">SELECT
patient_id,
first_name,
LAG(first_name, 1) OVER() AS previous_name
FROM patients;</code></pre>
</div>
</div>
</div>