doc-exports/docs/dli/sqlreference/dli_spark_max.html
Su, Xiaomeng 76a5b1ee83 dli_sqlreference_20240227
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com>
Co-authored-by: Su, Xiaomeng <suxiaomeng1@huawei.com>
Co-committed-by: Su, Xiaomeng <suxiaomeng1@huawei.com>
2024-03-27 22:02:33 +00:00

55 lines
5.4 KiB
HTML

<a name="dli_spark_max"></a><a name="dli_spark_max"></a>
<h1 class="topictitle1">max</h1>
<div id="body8662426"><p id="dli_spark_max__en-us_topic_0000001655540514_p18471163815215">This function is used to return the maximum value.</p>
<div class="section" id="dli_spark_max__en-us_topic_0000001655540514_section45291954203217"><h4 class="sectiontitle">Syntax</h4><pre class="screen" id="dli_spark_max__en-us_topic_0000001655540514_screen19928459112517">max(col)</pre>
</div>
<div class="section" id="dli_spark_max__en-us_topic_0000001655540514_section992014913317"><h4 class="sectiontitle">Parameters</h4>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="dli_spark_max__en-us_topic_0000001655540514_table1829154762513" frame="border" border="1" rules="all"><caption><b>Table 1 </b>Parameter</caption><thead align="left"><tr id="dli_spark_max__en-us_topic_0000001655540514_row8830104792517"><th align="left" class="cellrowborder" valign="top" width="15.310000000000002%" id="mcps1.3.3.2.2.5.1.1"><p id="dli_spark_max__en-us_topic_0000001655540514_p983074711252">Parameter</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="14.24%" id="mcps1.3.3.2.2.5.1.2"><p id="dli_spark_max__en-us_topic_0000001655540514_p6830124732517">Mandatory</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="22.689999999999998%" id="mcps1.3.3.2.2.5.1.3"><p id="dli_spark_max__en-us_topic_0000001655540514_p103752386613">Type</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="47.760000000000005%" id="mcps1.3.3.2.2.5.1.4"><p id="dli_spark_max__en-us_topic_0000001655540514_p08301547132513">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="dli_spark_max__en-us_topic_0000001655540514_row15830184792511"><td class="cellrowborder" valign="top" width="15.310000000000002%" headers="mcps1.3.3.2.2.5.1.1 "><p id="dli_spark_max__en-us_topic_0000001655540514_p683034714250">col</p>
</td>
<td class="cellrowborder" valign="top" width="14.24%" headers="mcps1.3.3.2.2.5.1.2 "><p id="dli_spark_max__en-us_topic_0000001655540514_p12830184752518">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="22.689999999999998%" headers="mcps1.3.3.2.2.5.1.3 "><p id="dli_spark_max__en-us_topic_0000001655540514_p20375113815618">Any type except BOOLEAN</p>
</td>
<td class="cellrowborder" valign="top" width="47.760000000000005%" headers="mcps1.3.3.2.2.5.1.4 "><p id="dli_spark_max__en-us_topic_0000001655540514_p9484232112711">The value can be of any type except BOOLEAN.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="dli_spark_max__en-us_topic_0000001655540514_section210162513312"><h4 class="sectiontitle">Return Values</h4><p id="dli_spark_max__en-us_topic_0000001655540514_p184124317231">The return value is of the DOUBLE type.</p>
<div class="note" id="dli_spark_max__en-us_topic_0000001655540514_note61422099395"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="dli_spark_max__en-us_topic_0000001655540514_p1540130121111">The return type is the same as the type of <strong id="dli_spark_max__en-us_topic_0000001655540514_b9899155914374">col</strong>. The return rules are as follows:</p>
<ul id="dli_spark_max__en-us_topic_0000001655540514_ul96131340111120"><li id="dli_spark_max__en-us_topic_0000001655540514_li561444018116">If the value of <strong id="dli_spark_max__en-us_topic_0000001655540514_b05414763810">col</strong> is <strong id="dli_spark_max__en-us_topic_0000001655540514_b125428733813">NULL</strong>, the row is not involved in calculation.</li><li id="dli_spark_max__en-us_topic_0000001655540514_li1061414404112">If the value of <strong id="dli_spark_max__en-us_topic_0000001655540514_b151111431173811">col</strong> is of the BOOLEAN type, it cannot be used for calculation.</li></ul>
</div></div>
</div>
<div class="section" id="dli_spark_max__en-us_topic_0000001655540514_section13277192233920"><h4 class="sectiontitle">Example Code</h4><ul id="dli_spark_max__en-us_topic_0000001655540514_ul1472918383362"><li id="dli_spark_max__en-us_topic_0000001655540514_li772910381360">Calculates the maximum inventory (items) of all offerings. An example command is as follows:<pre class="screen" id="dli_spark_max__en-us_topic_0000001655540514_screen118341346202811">select max(items) from warehouse;</pre>
<p id="dli_spark_max__en-us_topic_0000001655540514_p108341146192811">The command output is as follows:</p>
<pre class="screen" id="dli_spark_max__en-us_topic_0000001655540514_screen12834146122810">_c0
900 </pre>
</li><li id="dli_spark_max__en-us_topic_0000001655540514_li1899610485365">When used with <strong id="dli_spark_max__en-us_topic_0000001655540514_b860288173916">group by</strong>, it returns the maximum inventory of each warehouse. An example command is as follows:<pre class="screen" id="dli_spark_max__en-us_topic_0000001655540514_screen118351646182820">select warehourseId, max(items) from warehouse group by warehourseId;</pre>
<p id="dli_spark_max__en-us_topic_0000001655540514_p383554619283">The command output is as follows:</p>
<pre class="screen" id="dli_spark_max__en-us_topic_0000001655540514_screen5835146182813">warehouseId _c1
city1 200
city2 300
city3 400 </pre>
</li></ul>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dli_08_0474.html">Aggregate Functions</a></div>
</div>
</div>