blob: f12b5341c3f524a2ba26e9460799cffceae4e2d3 [file] [log] [blame]
<!doctype html>
<html lang="en" dir="ltr" class="docs-wrapper docs-doc-page docs-version-current plugin-docs plugin-id-default docs-doc-id-querying/sql-aggregations">
<head>
<meta charset="UTF-8">
<meta name="generator" content="Docusaurus v2.4.1">
<title data-rh="true">SQL aggregation functions | Apache® Druid</title><meta data-rh="true" name="viewport" content="width=device-width,initial-scale=1"><meta data-rh="true" name="twitter:card" content="summary_large_image"><meta data-rh="true" property="og:image" content="https://druid.apache.org/img/druid_nav.png"><meta data-rh="true" name="twitter:image" content="https://druid.apache.org/img/druid_nav.png"><meta data-rh="true" property="og:url" content="https://druid.apache.org/docs/28.0.0/querying/sql-aggregations"><meta data-rh="true" name="docusaurus_locale" content="en"><meta data-rh="true" name="docsearch:language" content="en"><meta data-rh="true" name="docusaurus_version" content="current"><meta data-rh="true" name="docusaurus_tag" content="docs-default-current"><meta data-rh="true" name="docsearch:version" content="current"><meta data-rh="true" name="docsearch:docusaurus_tag" content="docs-default-current"><meta data-rh="true" property="og:title" content="SQL aggregation functions | Apache® Druid"><meta data-rh="true" name="description" content="&lt;!--"><meta data-rh="true" property="og:description" content="&lt;!--"><link data-rh="true" rel="icon" href="/img/favicon.png"><link data-rh="true" rel="canonical" href="https://druid.apache.org/docs/28.0.0/querying/sql-aggregations"><link data-rh="true" rel="alternate" href="https://druid.apache.org/docs/28.0.0/querying/sql-aggregations" hreflang="en"><link data-rh="true" rel="alternate" href="https://druid.apache.org/docs/28.0.0/querying/sql-aggregations" hreflang="x-default"><link rel="preconnect" href="https://www.google-analytics.com">
<link rel="preconnect" href="https://www.googletagmanager.com">
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-131010415-1"></script>
<script>function gtag(){dataLayer.push(arguments)}window.dataLayer=window.dataLayer||[],gtag("js",new Date),gtag("config","UA-131010415-1",{})</script>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.2/css/all.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.4/clipboard.min.js"></script><link rel="stylesheet" href="/assets/css/styles.546f39eb.css">
<link rel="preload" href="/assets/js/runtime~main.0dcbfdea.js" as="script">
<link rel="preload" href="/assets/js/main.7f6fdf81.js" as="script">
</head>
<body class="navigation-with-keyboard">
<script>!function(){function t(t){document.documentElement.setAttribute("data-theme",t)}var e=function(){var t=null;try{t=new URLSearchParams(window.location.search).get("docusaurus-theme")}catch(t){}return t}()||function(){var t=null;try{t=localStorage.getItem("theme")}catch(t){}return t}();t(null!==e?e:"light")}()</script><div id="__docusaurus">
<div role="region" aria-label="Skip to main content"><a class="skipToContent_fXgn" href="#__docusaurus_skipToContent_fallback">Skip to main content</a></div><nav aria-label="Main" class="navbar navbar--fixed-top navbar--dark"><div class="navbar__inner"><div class="navbar__items"><button aria-label="Toggle navigation bar" aria-expanded="false" class="navbar__toggle clean-btn" type="button"><svg width="30" height="30" viewBox="0 0 30 30" aria-hidden="true"><path stroke="currentColor" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" d="M4 7h22M4 15h22M4 23h22"></path></svg></button><a class="navbar__brand" href="/"><div class="navbar__logo"><img src="/img/druid_nav.png" alt="Apache® Druid" class="themedImage_ToTc themedImage--light_HNdA"><img src="/img/druid_nav.png" alt="Apache® Druid" class="themedImage_ToTc themedImage--dark_i4oU"></div></a></div><div class="navbar__items navbar__items--right"><a class="navbar__item navbar__link" href="/technology">Technology</a><a class="navbar__item navbar__link" href="/use-cases">Use Cases</a><a class="navbar__item navbar__link" href="/druid-powered">Powered By</a><a class="navbar__item navbar__link" href="/docs/28.0.0/design/">Docs</a><a class="navbar__item navbar__link" href="/community/">Community</a><div class="navbar__item dropdown dropdown--hoverable dropdown--right"><a href="#" aria-haspopup="true" aria-expanded="false" role="button" class="navbar__link">Apache®</a><ul class="dropdown__menu"><li><a href="https://www.apache.org/" target="_blank" rel="noopener noreferrer" class="dropdown__link">Foundation<svg width="12" height="12" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_nPIU"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a></li><li><a href="https://apachecon.com/?ref=druid.apache.org" target="_blank" rel="noopener noreferrer" class="dropdown__link">Events<svg width="12" height="12" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_nPIU"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a></li><li><a href="https://www.apache.org/licenses/" target="_blank" rel="noopener noreferrer" class="dropdown__link">License<svg width="12" height="12" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_nPIU"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a></li><li><a href="https://www.apache.org/foundation/thanks.html" target="_blank" rel="noopener noreferrer" class="dropdown__link">Thanks<svg width="12" height="12" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_nPIU"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a></li><li><a href="https://www.apache.org/security/" target="_blank" rel="noopener noreferrer" class="dropdown__link">Security<svg width="12" height="12" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_nPIU"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a></li><li><a href="https://www.apache.org/foundation/sponsorship.html" target="_blank" rel="noopener noreferrer" class="dropdown__link">Sponsorship<svg width="12" height="12" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_nPIU"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a></li></ul></div><a class="navbar__item navbar__link" href="/downloads/">Download</a><div class="searchBox_ZlJk"><div class="navbar__search"><span aria-label="expand searchbar" role="button" class="search-icon" tabindex="0"></span><input type="search" id="search_input_react" placeholder="Loading..." aria-label="Search" class="navbar__search-input search-bar" disabled=""></div></div></div></div><div role="presentation" class="navbar-sidebar__backdrop"></div></nav><div id="__docusaurus_skipToContent_fallback" class="main-wrapper mainWrapper_z2l0 docsWrapper_BCFX"><button aria-label="Scroll back to top" class="clean-btn theme-back-to-top-button backToTopButton_sjWU" type="button"></button><div class="docPage__5DB"><aside class="theme-doc-sidebar-container docSidebarContainer_b6E3"><div class="sidebarViewport_Xe31"><div class="sidebar_njMd"><nav aria-label="Docs sidebar" class="menu thin-scrollbar menu_SIkG"><ul class="theme-doc-sidebar-menu menu__list"><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="/docs/28.0.0/design/">Getting started</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="/docs/28.0.0/tutorials/tutorial-msq-extern">Tutorials</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="/docs/28.0.0/design/architecture">Design</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="/docs/28.0.0/ingestion/">Ingestion</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="/docs/28.0.0/data-management/">Data management</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret menu__link--active" aria-expanded="true" href="/docs/28.0.0/querying/sql">Querying</a></div><ul style="display:block;overflow:visible;height:auto" class="menu__list"><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-2 menu__list-item"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret menu__link--active" aria-expanded="true" tabindex="0" href="/docs/28.0.0/querying/sql">Druid SQL</a></div><ul style="display:block;overflow:visible;height:auto" class="menu__list"><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/28.0.0/querying/sql">Overview and syntax</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/28.0.0/querying/tips-good-queries">Tips for writing good queries</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/28.0.0/querying/query-deep-storage">Query from deep storage</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/28.0.0/querying/sql-data-types">SQL data types</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/28.0.0/querying/sql-operators">Operators</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/28.0.0/querying/sql-scalar">Scalar functions</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link menu__link--active" aria-current="page" tabindex="0" href="/docs/28.0.0/querying/sql-aggregations">Aggregation functions</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/28.0.0/querying/sql-array-functions">Array functions</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/28.0.0/querying/sql-multivalue-string-functions">Multi-value string functions</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/28.0.0/querying/sql-json-functions">JSON functions</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/28.0.0/querying/sql-functions">All functions</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/28.0.0/querying/sql-query-context">SQL query context</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/28.0.0/querying/sql-metadata-tables">SQL metadata tables</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/28.0.0/querying/sql-translation">SQL query translation</a></li></ul></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/28.0.0/querying/">Native queries</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/28.0.0/querying/query-execution">Query execution</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/28.0.0/querying/troubleshooting">Troubleshooting</a></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-2 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" tabindex="0" href="/docs/28.0.0/querying/datasource">Concepts</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-2 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" tabindex="0" href="/docs/28.0.0/querying/timeseriesquery">Native query types</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-2 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" tabindex="0" href="/docs/28.0.0/querying/filters">Native query components</a></div></li></ul></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="/docs/28.0.0/api-reference/">API reference</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="/docs/28.0.0/configuration/">Configuration</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="/docs/28.0.0/operations/web-console">Operations</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="/docs/28.0.0/development/overview">Development</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="/docs/28.0.0/misc/papers-and-talks">Misc</a></div></li></ul></nav></div></div></aside><main class="docMainContainer_gTbr"><div class="container padding-top--md padding-bottom--lg"><div class="row"><div class="col docItemCol_VOVn"><div class="docItemContainer_Djhp"><article><nav class="theme-doc-breadcrumbs breadcrumbsContainer_Z_bl" aria-label="Breadcrumbs"><ul class="breadcrumbs" itemscope="" itemtype="https://schema.org/BreadcrumbList"><li class="breadcrumbs__item"><a aria-label="Home page" class="breadcrumbs__link" href="/"><svg viewBox="0 0 24 24" class="breadcrumbHomeIcon_YNFT"><path d="M10 19v-5h4v5c0 .55.45 1 1 1h3c.55 0 1-.45 1-1v-7h1.7c.46 0 .68-.57.33-.87L12.67 3.6c-.38-.34-.96-.34-1.34 0l-8.36 7.53c-.34.3-.13.87.33.87H5v7c0 .55.45 1 1 1h3c.55 0 1-.45 1-1z" fill="currentColor"></path></svg></a></li><li class="breadcrumbs__item"><span class="breadcrumbs__link">Querying</span><meta itemprop="position" content="1"></li><li class="breadcrumbs__item"><span class="breadcrumbs__link">Druid SQL</span><meta itemprop="position" content="2"></li><li itemscope="" itemprop="itemListElement" itemtype="https://schema.org/ListItem" class="breadcrumbs__item breadcrumbs__item--active"><span class="breadcrumbs__link" itemprop="name">Aggregation functions</span><meta itemprop="position" content="3"></li></ul></nav><div class="tocCollapsible_ETCw theme-doc-toc-mobile tocMobile_ITEo"><button type="button" class="clean-btn tocCollapsibleButton_TO0P">On this page</button></div><div class="theme-doc-markdown markdown"><header><h1>SQL aggregation functions</h1></header><div class="theme-admonition theme-admonition-info alert alert--info admonition_LlT9"><div class="admonitionHeading_tbUL"><span class="admonitionIcon_kALy"><svg viewBox="0 0 14 16"><path fill-rule="evenodd" d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"></path></svg></span>info</div><div class="admonitionContent_S0QG"><p> Apache Druid supports two query languages: Druid SQL and <a href="/docs/28.0.0/querying/">native queries</a>.
This document describes the SQL language.</p></div></div><p>You can use aggregation functions in the SELECT clause of any <a href="/docs/28.0.0/querying/sql">Druid SQL</a> query.</p><p>Filter any aggregator using the FILTER clause, for example:</p><div class="codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#bfc7d5;--prism-background-color:#292d3e"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-text codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#bfc7d5"><span class="token plain">SELECT </span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> SUM(added) FILTER(WHERE channel = &#x27;#en.wikipedia&#x27;)</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain">FROM wikipedia</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><p>The FILTER clause limits an aggregation query to only the rows that match the filter.
Druid translates the FILTER clause to a native <a href="/docs/28.0.0/querying/aggregations#filtered-aggregator">filtered aggregator</a>.
Two aggregators in the same SQL query may have different filters.</p><p>When no rows are selected, aggregation functions return their initial value. This can occur from the following:</p><ul><li>When no rows match the filter while aggregating values across an entire table without a grouping, or</li><li>When using filtered aggregations within a grouping.</li></ul><p>The initial value varies by aggregator. <code>COUNT</code> and the approximate count distinct sketch functions
always return 0 as the initial value.</p><p>In the aggregation functions supported by Druid, only <code>COUNT</code>, <code>ARRAY_AGG</code>, and <code>STRING_AGG</code> accept the DISTINCT keyword.</p><div class="theme-admonition theme-admonition-info alert alert--info admonition_LlT9"><div class="admonitionHeading_tbUL"><span class="admonitionIcon_kALy"><svg viewBox="0 0 14 16"><path fill-rule="evenodd" d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"></path></svg></span>info</div><div class="admonitionContent_S0QG"><p> The order of aggregation operations across segments is not deterministic. This means that non-commutative aggregation
functions can produce inconsistent results across the same query.</p><p> Functions that operate on an input type of &quot;float&quot; or &quot;double&quot; may also see these differences in aggregation
results across multiple query runs because of this. If precisely the same value is desired across multiple query runs,
consider using the <code>ROUND</code> function to smooth out the inconsistencies between queries.</p></div></div><table><thead><tr><th>Function</th><th>Notes</th><th>Default</th></tr></thead><tbody><tr><td><code>COUNT(*)</code></td><td>Counts the number of rows.</td><td><code>0</code></td></tr><tr><td><code>COUNT(DISTINCT expr)</code></td><td>Counts distinct values of <code>expr</code>.<br><br>When <code>useApproximateCountDistinct</code> is set to &quot;true&quot; (the default), this is an alias for <code>APPROX_COUNT_DISTINCT</code>. The specific algorithm depends on the value of <a href="/docs/28.0.0/configuration/#sql"><code>druid.sql.approxCountDistinct.function</code></a>. In this mode, you can use strings, numbers, or prebuilt sketches. If counting prebuilt sketches, the prebuilt sketch type must match the selected algorithm.<br><br>When <code>useApproximateCountDistinct</code> is set to &quot;false&quot;, the computation will be exact. In this case, <code>expr</code> must be string or numeric, since exact counts are not possible using prebuilt sketches. In exact mode, only one distinct count per query is permitted unless <code>useGroupingSetForExactDistinct</code> is enabled.<br><br>Counts each distinct value in a <a href="/docs/28.0.0/querying/multi-value-dimensions"><code>multi-value</code></a>-row separately.</td><td><code>0</code></td></tr><tr><td><code>SUM(expr)</code></td><td>Sums numbers.</td><td><code>null</code> or <code>0</code> if <code>druid.generic.useDefaultValueForNull=true</code> (legacy mode)</td></tr><tr><td><code>MIN(expr)</code></td><td>Takes the minimum of numbers.</td><td><code>null</code> or <code>9223372036854775807</code> (maximum LONG value) if <code>druid.generic.useDefaultValueForNull=true</code> (legacy mode)</td></tr><tr><td><code>MAX(expr)</code></td><td>Takes the maximum of numbers.</td><td><code>null</code> or <code>-9223372036854775808</code> (minimum LONG value) if <code>druid.generic.useDefaultValueForNull=true</code> (legacy mode)</td></tr><tr><td><code>AVG(expr)</code></td><td>Averages numbers.</td><td><code>null</code> or <code>0</code> if <code>druid.generic.useDefaultValueForNull=true</code> (legacy mode)</td></tr><tr><td><code>APPROX_COUNT_DISTINCT(expr)</code></td><td>Counts distinct values of <code>expr</code> using an approximate algorithm. The <code>expr</code> can be a regular column or a prebuilt sketch column.<br><br>The specific algorithm depends on the value of <a href="/docs/28.0.0/configuration/#sql"><code>druid.sql.approxCountDistinct.function</code></a>. By default, this is <code>APPROX_COUNT_DISTINCT_BUILTIN</code>. If the <a href="/docs/28.0.0/development/extensions-core/datasketches-extension">DataSketches extension</a> is loaded, you can set it to <code>APPROX_COUNT_DISTINCT_DS_HLL</code> or <code>APPROX_COUNT_DISTINCT_DS_THETA</code>.<br><br>When run on prebuilt sketch columns, the sketch column type must match the implementation of this function. For example: when <code>druid.sql.approxCountDistinct.function</code> is set to <code>APPROX_COUNT_DISTINCT_BUILTIN</code>, this function runs on prebuilt hyperUnique columns, but not on prebuilt HLLSketchBuild columns.</td><td></td></tr><tr><td><code>APPROX_COUNT_DISTINCT_BUILTIN(expr)</code></td><td><em>Usage note:</em> consider using <code>APPROX_COUNT_DISTINCT_DS_HLL</code> instead, which offers better accuracy in many cases.<br><br>Counts distinct values of <code>expr</code> using Druid&#x27;s built-in &quot;cardinality&quot; or &quot;hyperUnique&quot; aggregators, which implement a variant of <a href="http://algo.inria.fr/flajolet/Publications/FlFuGaMe07.pdf" target="_blank" rel="noopener noreferrer">HyperLogLog</a>. The <code>expr</code> can be a string, a number, or a prebuilt hyperUnique column. Results are always approximate, regardless of the value of <code>useApproximateCountDistinct</code>.</td><td></td></tr><tr><td><code>APPROX_QUANTILE(expr, probability, [resolution])</code></td><td><em>Deprecated.</em> Use <code>APPROX_QUANTILE_DS</code> instead, which provides a superior distribution-independent algorithm with formal error guarantees.<br><br>Computes approximate quantiles on numeric or <a href="/docs/28.0.0/development/extensions-core/approximate-histograms#approximate-histogram-aggregator">approxHistogram</a> expressions. <code>probability</code> should be between 0 and 1, exclusive. <code>resolution</code> is the number of centroids to use for the computation. Higher resolutions will give more precise results but also have higher overhead. If not provided, the default resolution is 50. Load the <a href="/docs/28.0.0/development/extensions-core/approximate-histograms">approximate histogram extension</a> to use this function.</td><td><code>NaN</code></td></tr><tr><td><code>APPROX_QUANTILE_FIXED_BUCKETS(expr, probability, numBuckets, lowerLimit, upperLimit, [outlierHandlingMode])</code></td><td>Computes approximate quantiles on numeric or <a href="/docs/28.0.0/development/extensions-core/approximate-histograms#fixed-buckets-histogram">fixed buckets histogram</a> expressions. <code>probability</code> should be between 0 and 1, exclusive. The <code>numBuckets</code>, <code>lowerLimit</code>, <code>upperLimit</code>, and <code>outlierHandlingMode</code> parameters are described in the fixed buckets histogram documentation. Load the <a href="/docs/28.0.0/development/extensions-core/approximate-histograms">approximate histogram extension</a> to use this function.</td><td><code>0.0</code></td></tr><tr><td><code>BLOOM_FILTER(expr, numEntries)</code></td><td>Computes a bloom filter from values produced by <code>expr</code>, with <code>numEntries</code> maximum number of distinct values before false positive rate increases. See <a href="/docs/28.0.0/development/extensions-core/bloom-filter">bloom filter extension</a> documentation for additional details.</td><td>Empty base64 encoded bloom filter STRING</td></tr><tr><td><code>VAR_POP(expr)</code></td><td>Computes variance population of <code>expr</code>. See <a href="/docs/28.0.0/development/extensions-core/stats">stats extension</a> documentation for additional details.</td><td><code>null</code> or <code>0</code> if <code>druid.generic.useDefaultValueForNull=true</code> (legacy mode)</td></tr><tr><td><code>VAR_SAMP(expr)</code></td><td>Computes variance sample of <code>expr</code>. See <a href="/docs/28.0.0/development/extensions-core/stats">stats extension</a> documentation for additional details.</td><td><code>null</code> or <code>0</code> if <code>druid.generic.useDefaultValueForNull=true</code> (legacy mode)</td></tr><tr><td><code>VARIANCE(expr)</code></td><td>Computes variance sample of <code>expr</code>. See <a href="/docs/28.0.0/development/extensions-core/stats">stats extension</a> documentation for additional details.</td><td><code>null</code> or <code>0</code> if <code>druid.generic.useDefaultValueForNull=true</code> (legacy mode)</td></tr><tr><td><code>STDDEV_POP(expr)</code></td><td>Computes standard deviation population of <code>expr</code>. See <a href="/docs/28.0.0/development/extensions-core/stats">stats extension</a> documentation for additional details.</td><td><code>null</code> or <code>0</code> if <code>druid.generic.useDefaultValueForNull=true</code> (legacy mode)</td></tr><tr><td><code>STDDEV_SAMP(expr)</code></td><td>Computes standard deviation sample of <code>expr</code>. See <a href="/docs/28.0.0/development/extensions-core/stats">stats extension</a> documentation for additional details.</td><td><code>null</code> or <code>0</code> if <code>druid.generic.useDefaultValueForNull=true</code> (legacy mode)</td></tr><tr><td><code>STDDEV(expr)</code></td><td>Computes standard deviation sample of <code>expr</code>. See <a href="/docs/28.0.0/development/extensions-core/stats">stats extension</a> documentation for additional details.</td><td><code>null</code> or <code>0</code> if <code>druid.generic.useDefaultValueForNull=true</code> (legacy mode)</td></tr><tr><td><code>EARLIEST(expr, [maxBytesPerValue])</code></td><td>Returns the earliest value of <code>expr</code>.<br>If <code>expr</code> comes from a relation with a timestamp column (like <code>__time</code> in a Druid datasource), the &quot;earliest&quot; is taken from the row with the overall earliest non-null value of the timestamp column.<br>If the earliest non-null value of the timestamp column appears in multiple rows, the <code>expr</code> may be taken from any of those rows. If <code>expr</code> does not come from a relation with a timestamp, then it is simply the first value encountered.<br><br>If <code>expr</code> is a string or complex type <code>maxBytesPerValue</code> amount of space is allocated for the aggregation. Strings longer than this limit are truncated. The <code>maxBytesPerValue</code> parameter should be set as low as possible, since high values will lead to wasted memory.<br>If <code>maxBytesPerValue</code>is omitted; it defaults to <code>1024</code>.</td><td><code>null</code> or <code>0</code>/<code>&#x27;&#x27;</code> if <code>druid.generic.useDefaultValueForNull=true</code> (legacy mode)</td></tr><tr><td><code>EARLIEST_BY(expr, timestampExpr, [maxBytesPerValue])</code></td><td>Returns the earliest value of <code>expr</code>.<br>The earliest value of <code>expr</code> is taken from the row with the overall earliest non-null value of <code>timestampExpr</code>. <br>If the earliest non-null value of <code>timestampExpr</code> appears in multiple rows, the <code>expr</code> may be taken from any of those rows.<br><br>If <code>expr</code> is a string or complex type <code>maxBytesPerValue</code> amount of space is allocated for the aggregation. Strings longer than this limit are truncated. The <code>maxBytesPerValue</code> parameter should be set as low as possible, since high values will lead to wasted memory.<br>If <code>maxBytesPerValue</code>is omitted; it defaults to <code>1024</code>.</td><td><code>null</code> or <code>0</code>/<code>&#x27;&#x27;</code> if <code>druid.generic.useDefaultValueForNull=true</code> (legacy mode)</td></tr><tr><td><code>LATEST(expr, [maxBytesPerValue])</code></td><td>Returns the latest value of <code>expr</code><br>The <code>expr</code> must come from a relation with a timestamp column (like <code>__time</code> in a Druid datasource) and the &quot;latest&quot; is taken from the row with the overall latest non-null value of the timestamp column.<br>If the latest non-null value of the timestamp column appears in multiple rows, the <code>expr</code> may be taken from any of those rows.<br><br>If <code>expr</code> is a string or complex type <code>maxBytesPerValue</code> amount of space is allocated for the aggregation. Strings longer than this limit are truncated. The <code>maxBytesPerValue</code> parameter should be set as low as possible, since high values will lead to wasted memory.<br>If <code>maxBytesPerValue</code>is omitted; it defaults to <code>1024</code>.</td><td><code>null</code> or <code>0</code>/<code>&#x27;&#x27;</code> if <code>druid.generic.useDefaultValueForNull=true</code> (legacy mode)</td></tr><tr><td><code>LATEST_BY(expr, timestampExpr, [maxBytesPerValue])</code></td><td>Returns the latest value of <code>expr</code>.<br>The latest value of <code>expr</code> is taken from the row with the overall latest non-null value of <code>timestampExpr</code>.<br>If the overall latest non-null value of <code>timestampExpr</code> appears in multiple rows, the <code>expr</code> may be taken from any of those rows.<br><br>If <code>expr</code> is a string or complex type <code>maxBytesPerValue</code> amount of space is allocated for the aggregation. Strings longer than this limit are truncated. The <code>maxBytesPerValue</code> parameter should be set as low as possible, since high values will lead to wasted memory.<br>If <code>maxBytesPerValue</code>is omitted; it defaults to <code>1024</code>.</td><td><code>null</code> or <code>0</code>/<code>&#x27;&#x27;</code> if <code>druid.generic.useDefaultValueForNull=true</code> (legacy mode)</td></tr><tr><td><code>ANY_VALUE(expr, [maxBytesPerValue])</code></td><td>Returns any value of <code>expr</code> including null. This aggregator can simplify and optimize the performance by returning the first encountered value (including <code>null</code>).<br><br>If <code>expr</code> is a string or complex type <code>maxBytesPerValue</code> amount of space is allocated for the aggregation. Strings longer than this limit are truncated. The <code>maxBytesPerValue</code> parameter should be set as low as possible, since high values will lead to wasted memory.<br>If <code>maxBytesPerValue</code>is omitted; it defaults to <code>1024</code>.</td><td><code>null</code> or <code>0</code>/<code>&#x27;&#x27;</code> if <code>druid.generic.useDefaultValueForNull=true</code> (legacy mode)</td></tr><tr><td><code>GROUPING(expr, expr...)</code></td><td>Returns a number to indicate which groupBy dimension is included in a row, when using <code>GROUPING SETS</code>. Refer to <a href="/docs/28.0.0/querying/aggregations#grouping-aggregator">additional documentation</a> on how to infer this number.</td><td>N/A</td></tr><tr><td><code>ARRAY_AGG(expr, [size])</code></td><td>Collects all values of <code>expr</code> into an ARRAY, including null values, with <code>size</code> in bytes limit on aggregation size (default of 1024 bytes). If the aggregated array grows larger than the maximum size in bytes, the query will fail. Use of <code>ORDER BY</code> within the <code>ARRAY_AGG</code> expression is not currently supported, and the ordering of results within the output array may vary depending on processing order.</td><td><code>null</code></td></tr><tr><td><code>ARRAY_AGG(DISTINCT expr, [size])</code></td><td>Collects all distinct values of <code>expr</code> into an ARRAY, including null values, with <code>size</code> in bytes limit on aggregation size (default of 1024 bytes) per aggregate. If the aggregated array grows larger than the maximum size in bytes, the query will fail. Use of <code>ORDER BY</code> within the <code>ARRAY_AGG</code> expression is not currently supported, and the ordering of results will be based on the default for the element type.</td><td><code>null</code></td></tr><tr><td><code>ARRAY_CONCAT_AGG(expr, [size])</code></td><td>Concatenates all array <code>expr</code> into a single ARRAY, with <code>size</code> in bytes limit on aggregation size (default of 1024 bytes). Input <code>expr</code> <em>must</em> be an array. Null <code>expr</code> will be ignored, but any null values within an <code>expr</code> <em>will</em> be included in the resulting array. If the aggregated array grows larger than the maximum size in bytes, the query will fail. Use of <code>ORDER BY</code> within the <code>ARRAY_CONCAT_AGG</code> expression is not currently supported, and the ordering of results within the output array may vary depending on processing order.</td><td><code>null</code></td></tr><tr><td><code>ARRAY_CONCAT_AGG(DISTINCT expr, [size])</code></td><td>Concatenates all distinct values of all array <code>expr</code> into a single ARRAY, with <code>size</code> in bytes limit on aggregation size (default of 1024 bytes) per aggregate. Input <code>expr</code> <em>must</em> be an array. Null <code>expr</code> will be ignored, but any null values within an <code>expr</code> <em>will</em> be included in the resulting array. If the aggregated array grows larger than the maximum size in bytes, the query will fail. Use of <code>ORDER BY</code> within the <code>ARRAY_CONCAT_AGG</code> expression is not currently supported, and the ordering of results will be based on the default for the element type.</td><td><code>null</code></td></tr><tr><td><code>STRING_AGG([DISTINCT] expr, [separator, [size]])</code></td><td>Collects all values (or all distinct values) of <code>expr</code> into a single STRING, ignoring null values. Each value is joined by an optional <code>separator</code>, which must be a literal STRING. If the <code>separator</code> is not provided, strings are concatenated without a separator.<br><br>An optional <code>size</code> in bytes can be supplied to limit aggregation size (default of 1024 bytes). If the aggregated string grows larger than the maximum size in bytes, the query will fail. Use of <code>ORDER BY</code> within the <code>STRING_AGG</code> expression is not currently supported, and the ordering of results within the output string may vary depending on processing order.</td><td><code>null</code> or <code>&#x27;&#x27;</code> if <code>druid.generic.useDefaultValueForNull=true</code> (legacy mode)</td></tr><tr><td><code>LISTAGG([DISTINCT] expr, [separator, [size]])</code></td><td>Synonym for <code>STRING_AGG</code>.</td><td><code>null</code> or <code>&#x27;&#x27;</code> if <code>druid.generic.useDefaultValueForNull=true</code> (legacy mode)</td></tr><tr><td><code>BIT_AND(expr)</code></td><td>Performs a bitwise AND operation on all input values.</td><td><code>null</code> or <code>0</code> if <code>druid.generic.useDefaultValueForNull=true</code> (legacy mode)</td></tr><tr><td><code>BIT_OR(expr)</code></td><td>Performs a bitwise OR operation on all input values.</td><td><code>null</code> or <code>0</code> if <code>druid.generic.useDefaultValueForNull=true</code> (legacy mode)</td></tr><tr><td><code>BIT_XOR(expr)</code></td><td>Performs a bitwise XOR operation on all input values.</td><td><code>null</code> or <code>0</code> if <code>druid.generic.useDefaultValueForNull=true</code> (legacy mode)</td></tr></tbody></table><h2 class="anchor anchorWithStickyNavbar_LWe7" id="sketch-functions">Sketch functions<a href="#sketch-functions" class="hash-link" aria-label="Direct link to Sketch functions" title="Direct link to Sketch functions"></a></h2><p>These functions create sketch objects that you can use to perform fast, approximate analyses.
For advice on choosing approximate aggregation functions, check out our <a href="/docs/28.0.0/querying/aggregations#approx">approximate aggregations documentation</a>.
To operate on sketch objects, also see the <a href="/docs/28.0.0/querying/sql-scalar#sketch-functions">DataSketches post aggregator functions</a>.</p><h3 class="anchor anchorWithStickyNavbar_LWe7" id="hll-sketch-functions">HLL sketch functions<a href="#hll-sketch-functions" class="hash-link" aria-label="Direct link to HLL sketch functions" title="Direct link to HLL sketch functions"></a></h3><p>Load the <a href="/docs/28.0.0/development/extensions-core/datasketches-extension">DataSketches extension</a> to use the following functions.</p><table><thead><tr><th>Function</th><th>Notes</th><th>Default</th></tr></thead><tbody><tr><td><code>APPROX_COUNT_DISTINCT_DS_HLL(expr, [lgK, tgtHllType])</code></td><td>Counts distinct values of <code>expr</code>, which can be a regular column or an <a href="/docs/28.0.0/development/extensions-core/datasketches-hll">HLL sketch</a> column. Results are always approximate, regardless of the value of <a href="/docs/28.0.0/querying/sql-query-context"><code>useApproximateCountDistinct</code></a>. The <code>lgK</code> and <code>tgtHllType</code> parameters here are, like the equivalents in the <a href="/docs/28.0.0/development/extensions-core/datasketches-hll#aggregators">aggregator</a>, described in the HLL sketch documentation. See also <code>COUNT(DISTINCT expr)</code>.</td><td><code>0</code></td></tr><tr><td><code>DS_HLL(expr, [lgK, tgtHllType])</code></td><td>Creates an <a href="/docs/28.0.0/development/extensions-core/datasketches-hll">HLL sketch</a> on the values of <code>expr</code>, which can be a regular column or a column containing HLL sketches. The <code>lgK</code> and <code>tgtHllType</code> parameters are described in the HLL sketch documentation.</td><td><code>&#x27;0&#x27;</code> (STRING)</td></tr></tbody></table><h3 class="anchor anchorWithStickyNavbar_LWe7" id="theta-sketch-functions">Theta sketch functions<a href="#theta-sketch-functions" class="hash-link" aria-label="Direct link to Theta sketch functions" title="Direct link to Theta sketch functions"></a></h3><p>Load the <a href="/docs/28.0.0/development/extensions-core/datasketches-extension">DataSketches extension</a> to use the following functions.</p><table><thead><tr><th>Function</th><th>Notes</th><th>Default</th></tr></thead><tbody><tr><td><code>APPROX_COUNT_DISTINCT_DS_THETA(expr, [size])</code></td><td>Counts distinct values of <code>expr</code>, which can be a regular column or a <a href="/docs/28.0.0/development/extensions-core/datasketches-theta">Theta sketch</a> column. Results are always approximate, regardless of the value of <a href="/docs/28.0.0/querying/sql-query-context"><code>useApproximateCountDistinct</code></a>. The <code>size</code> parameter is described in the Theta sketch documentation. See also <code>COUNT(DISTINCT expr)</code>.</td><td><code>0</code></td></tr><tr><td><code>DS_THETA(expr, [size])</code></td><td>Creates a <a href="/docs/28.0.0/development/extensions-core/datasketches-theta">Theta sketch</a> on the values of <code>expr</code>, which can be a regular column or a column containing Theta sketches. The <code>size</code> parameter is described in the Theta sketch documentation.</td><td><code>&#x27;0.0&#x27;</code> (STRING)</td></tr></tbody></table><h3 class="anchor anchorWithStickyNavbar_LWe7" id="quantiles-sketch-functions">Quantiles sketch functions<a href="#quantiles-sketch-functions" class="hash-link" aria-label="Direct link to Quantiles sketch functions" title="Direct link to Quantiles sketch functions"></a></h3><p>Load the <a href="/docs/28.0.0/development/extensions-core/datasketches-extension">DataSketches extension</a> to use the following functions.</p><table><thead><tr><th>Function</th><th>Notes</th><th>Default</th></tr></thead><tbody><tr><td><code>APPROX_QUANTILE_DS(expr, probability, [k])</code></td><td>Computes approximate quantiles on numeric or <a href="/docs/28.0.0/development/extensions-core/datasketches-quantiles">Quantiles sketch</a> expressions. The <code>probability</code> value should be between 0 and 1, exclusive. The <code>k</code> parameter is described in the Quantiles sketch documentation.<br><br>See the <a href="/docs/28.0.0/querying/sql-translation#approximations">known issue</a> with this function.</td><td><code>NaN</code></td></tr><tr><td><code>DS_QUANTILES_SKETCH(expr, [k])</code></td><td>Creates a <a href="/docs/28.0.0/development/extensions-core/datasketches-quantiles">Quantiles sketch</a> on the values of <code>expr</code>, which can be a regular column or a column containing quantiles sketches. The <code>k</code> parameter is described in the Quantiles sketch documentation.<br><br>See the <a href="/docs/28.0.0/querying/sql-translation#approximations">known issue</a> with this function.</td><td><code>&#x27;0&#x27;</code> (STRING)</td></tr></tbody></table><h3 class="anchor anchorWithStickyNavbar_LWe7" id="tuple-sketch-functions">Tuple sketch functions<a href="#tuple-sketch-functions" class="hash-link" aria-label="Direct link to Tuple sketch functions" title="Direct link to Tuple sketch functions"></a></h3><p>Load the <a href="/docs/28.0.0/development/extensions-core/datasketches-extension">DataSketches extension</a> to use the following functions.</p><table><thead><tr><th>Function</th><th>Notes</th><th>Default</th></tr></thead><tbody><tr><td><code>DS_TUPLE_DOUBLES(expr, [nominalEntries])</code></td><td>Creates a <a href="/docs/28.0.0/development/extensions-core/datasketches-tuple">Tuple sketch</a> on the values of <code>expr</code> which is a column containing Tuple sketches which contain an array of double values as their Summary Objects. The <code>nominalEntries</code> override parameter is optional and described in the Tuple sketch documentation.</td><td></td></tr><tr><td><code>DS_TUPLE_DOUBLES(dimensionColumnExpr, metricColumnExpr, ..., [nominalEntries])</code></td><td>Creates a <a href="/docs/28.0.0/development/extensions-core/datasketches-tuple">Tuple sketch</a> which contains an array of double values as its Summary Object based on the dimension value of <code>dimensionColumnExpr</code> and the numeric metric values contained in one or more <code>metricColumnExpr</code> columns. If the last value of the array is a numeric literal, Druid assumes that the value is an override parameter for <a href="/docs/28.0.0/development/extensions-core/datasketches-tuple">nominal entries</a>.</td><td></td></tr></tbody></table><h3 class="anchor anchorWithStickyNavbar_LWe7" id="t-digest-sketch-functions">T-Digest sketch functions<a href="#t-digest-sketch-functions" class="hash-link" aria-label="Direct link to T-Digest sketch functions" title="Direct link to T-Digest sketch functions"></a></h3><p>Load the T-Digest extension to use the following functions. See the <a href="/docs/28.0.0/development/extensions-contrib/tdigestsketch-quantiles">T-Digest extension</a> for additional details and for more information on these functions.</p><table><thead><tr><th>Function</th><th>Notes</th><th>Default</th></tr></thead><tbody><tr><td><code>TDIGEST_QUANTILE(expr, quantileFraction, [compression])</code></td><td>Builds a T-Digest sketch on values produced by <code>expr</code> and returns the value for the quantile. Compression parameter (default value 100) determines the accuracy and size of the sketch. Higher compression means higher accuracy but more space to store sketches.</td><td><code>Double.NaN</code></td></tr><tr><td><code>TDIGEST_GENERATE_SKETCH(expr, [compression])</code></td><td>Builds a T-Digest sketch on values produced by <code>expr</code>. Compression parameter (default value 100) determines the accuracy and size of the sketch Higher compression means higher accuracy but more space to store sketches.</td><td>Empty base64 encoded T-Digest sketch STRING</td></tr></tbody></table></div></article><nav class="pagination-nav docusaurus-mt-lg" aria-label="Docs pages"><a class="pagination-nav__link pagination-nav__link--prev" href="/docs/28.0.0/querying/sql-scalar"><div class="pagination-nav__sublabel">Previous</div><div class="pagination-nav__label">Scalar functions</div></a><a class="pagination-nav__link pagination-nav__link--next" href="/docs/28.0.0/querying/sql-array-functions"><div class="pagination-nav__sublabel">Next</div><div class="pagination-nav__label">Array functions</div></a></nav></div></div><div class="col col--3"><div class="tableOfContents_bqdL thin-scrollbar theme-doc-toc-desktop"><ul class="table-of-contents table-of-contents__left-border"><li><a href="#sketch-functions" class="table-of-contents__link toc-highlight">Sketch functions</a><ul><li><a href="#hll-sketch-functions" class="table-of-contents__link toc-highlight">HLL sketch functions</a></li><li><a href="#theta-sketch-functions" class="table-of-contents__link toc-highlight">Theta sketch functions</a></li><li><a href="#quantiles-sketch-functions" class="table-of-contents__link toc-highlight">Quantiles sketch functions</a></li><li><a href="#tuple-sketch-functions" class="table-of-contents__link toc-highlight">Tuple sketch functions</a></li><li><a href="#t-digest-sketch-functions" class="table-of-contents__link toc-highlight">T-Digest sketch functions</a></li></ul></li></ul></div></div></div></div></main></div></div><footer class="footer"><div class="container container-fluid"><div class="footer__bottom text--center"><div class="margin-bottom--sm"><img src="/img/favicon.png" class="themedImage_ToTc themedImage--light_HNdA footer__logo"><img src="/img/favicon.png" class="themedImage_ToTc themedImage--dark_i4oU footer__logo"></div><div class="footer__copyright">Copyright © 2023 Apache Software Foundation. Except where otherwise noted, licensed under CC BY-SA 4.0. Apache Druid, Druid, and the Druid logo are either registered trademarks or trademarks of The Apache Software Foundation in the United States and other countries.</div></div></div></footer></div>
<script src="/assets/js/runtime~main.0dcbfdea.js"></script>
<script src="/assets/js/main.7f6fdf81.js"></script>
</body>
</html>