id stringlengths 36 36 | document stringlengths 3 3k | metadata stringlengths 23 69 | embeddings listlengths 384 384 |
|---|---|---|---|
cfe2015b-fac9-4257-a23c-60de6d80a190 | Introduced in: v20.1
Adds a specified number of quarters to a date, a date with time or a string-encoded date or date with time.
Syntax
sql
addQuarters(datetime, num)
Arguments
datetime
β Date or date with time to add specified number of quarters to.
Date
or
Date32
or
DateTime
or
DateTime64
or
Str... | {"source_file": "date-time-functions.md"} | [
0.024902256205677986,
0.012101779691874981,
-0.02603720687329769,
0.07405232638120651,
-0.11551982164382935,
0.055309709161520004,
-0.029636669903993607,
0.004250951111316681,
-0.035106413066387177,
0.037272002547979355,
0.047785814851522446,
-0.13822412490844727,
-0.034195173531770706,
-0... |
f7d6c308-9911-4e7f-b396-ced137562c0c | addTupleOfIntervals {#addTupleOfIntervals}
Introduced in: v22.11
Consecutively adds a tuple of intervals to a date or a date with time.
Syntax
sql
addTupleOfIntervals(datetime, intervals)
Arguments
datetime
β Date or date with time to add intervals to.
Date
or
Date32
or
DateTime
or
DateTime64
in... | {"source_file": "date-time-functions.md"} | [
-0.06884794682264328,
-0.032780613750219345,
-0.0011472468031570315,
0.09852084517478943,
-0.061835870146751404,
0.07670015841722488,
-0.008548072539269924,
-0.013138559646904469,
-0.06311939656734467,
-0.021581143140792847,
0.042757175862789154,
-0.10783727467060089,
-0.0017537957755848765,... |
9c163f73-c018-47fd-bf1d-a57119bded7a | Returned value
Returns
datetime
plus
num
years
Date
or
Date32
or
DateTime
or
DateTime64
Examples
Add years to different date types
sql title=Query
WITH
toDate('2024-01-01') AS date,
toDateTime('2024-01-01 00:00:00') AS date_time,
'2024-01-01 00:00:00' AS date_time_string
SELECT
addYea... | {"source_file": "date-time-functions.md"} | [
-0.02262466959655285,
0.01149055641144514,
0.02476535178720951,
0.04485534131526947,
-0.044337376952171326,
0.03137432783842087,
-0.01166491862386465,
0.015017544850707054,
-0.03664400056004524,
-0.019393883645534515,
0.048211704939603806,
-0.12299859523773193,
-0.003642205148935318,
0.019... |
e76aa924-083c-41b5-a487-a751eba557f1 | Examples
Calculate age in hours
sql title=Query
SELECT age('hour', toDateTime('2018-01-01 22:30:00'), toDateTime('2018-01-02 23:00:00'))
response title=Response
ββage('hour', toDateTime('2018-01-01 22:30:00'), toDateTime('2018-01-02 23:00:00'))ββ
β ... | {"source_file": "date-time-functions.md"} | [
0.029225939884781837,
0.06331998854875565,
0.045778512954711914,
0.08457746356725693,
-0.0528092198073864,
-0.03042449615895748,
0.014064607210457325,
0.010009977966547012,
-0.07782531529664993,
0.044483259320259094,
0.07683174312114716,
-0.1410343497991562,
0.011735287494957447,
0.0139972... |
56722826-efba-4021-a35e-b0ad6b87f630 | Arguments
date_or_datetime
β The value to change.
Date
or
Date32
or
DateTime
or
DateTime64
value
β The new value.
(U)Int*
Returned value
Returns a value of the same type as
date_or_datetime
with modified month component.
Date
or
Date32
or
DateTime
or
DateTime64
Examples
Usage example
... | {"source_file": "date-time-functions.md"} | [
-0.004865275230258703,
0.0036045906599611044,
-0.035738181322813034,
0.053499363362789154,
-0.013964050449430943,
0.011149575002491474,
0.015020581893622875,
0.04208538681268692,
0.022584734484553337,
0.06639280170202255,
-0.0020064085256308317,
-0.0757773146033287,
-0.037900183349847794,
... |
3d493295-5bbd-424b-a7d3-d42f1a725762 | Aliases
:
timestampDiff
,
TIMESTAMP_DIFF
,
DATE_DIFF
,
date_diff
,
timestamp_diff
Arguments
unit
β The type of interval for result.
| Unit | Possible values |
|-------------|-------------------------------------------|
| nanosecond |
nanosecond
,
nanoseconds
,
ns
... | {"source_file": "date-time-functions.md"} | [
0.006658875849097967,
-0.005870324093848467,
-0.07163051515817642,
-0.013543317094445229,
-0.043245017528533936,
-0.08781329542398453,
-0.02469080686569214,
0.0890519842505455,
-0.042135316878557205,
-0.0060193478129804134,
0.04128143563866615,
-0.11196882277727127,
0.05505303665995598,
-0... |
bc83f244-efe5-44ee-811b-515368d032d8 | sql title=Query
WITH toDateTime('2021-04-14 11:22:33') AS date_value
SELECT
dateName('year', date_value),
dateName('month', date_value),
dateName('day', date_value)
response title=Response
ββdateName('year', date_value)ββ¬βdateName('month', date_value)ββ¬βdateName('day', date_value)ββ
β 2021 ... | {"source_file": "date-time-functions.md"} | [
0.01932656019926071,
0.03188323229551315,
0.007885034196078777,
0.09277521073818207,
-0.09399482607841492,
-0.032218240201473236,
0.003920502029359341,
0.03708036243915558,
-0.06896010041236877,
-0.011605658568441868,
0.05326396971940994,
-0.09607618302106857,
0.03248876333236694,
-0.00112... |
eca328bf-52f5-4235-92b7-56be2a010760 | Truncate with specified timezone
sql title=Query
SELECT now(), dateTrunc('hour', now(), 'Asia/Istanbul');
response title=Response
ββββββββββββββββnow()ββ¬βdateTrunc('hour', now(), 'Asia/Istanbul')βββ
β 2020-09-28 10:46:26 β 2020-09-28 13:00:00 β
βββββββββββββββββββββββ΄βββββββββββββββββββββββββ... | {"source_file": "date-time-functions.md"} | [
0.05634477734565735,
0.08323419839143753,
0.0537065714597702,
0.04498304799199104,
-0.05242495611310005,
-0.027115844190120697,
0.048543062061071396,
0.06042250245809555,
0.03095064125955105,
-0.01807566173374653,
-0.025867655873298645,
-0.05258931964635849,
0.0026766606606543064,
0.016868... |
e7f6433b-a769-446f-aa54-668abfa66505 | In ClickHouse versions earlier than v25.1,
%f
prints as many digits as specified by the scale of the DateTime64 instead of fixed 6 digits.
In ClickHouse versions earlier than v23.4,
%M
prints the minute (00-59) instead of the full month name (January-December).
Syntax
sql
formatDateTime(datetime, format[, t... | {"source_file": "date-time-functions.md"} | [
0.06410744786262512,
-0.0082505838945508,
-0.0501469150185585,
0.05443244054913521,
-0.04431035742163658,
-0.011443974450230598,
-0.004324694629758596,
0.02737266570329666,
-0.02734399400651455,
-0.018752869218587875,
0.0029928633011877537,
-0.058548908680677414,
-0.0219448022544384,
-0.03... |
c6c1de88-d2f8-4720-8008-feeed25bde78 | The opposite operation of this function is
parseDateTimeInJodaSyntax
.
Using replacement fields, you can define a pattern for the resulting string.
Replacement fields:
| Placeholder | Description | Presentation | Examples |
|-------------|-------------|-------------|----------|
| G | era | text | AD |
| C | cent... | {"source_file": "date-time-functions.md"} | [
0.01698252186179161,
0.07652264088392258,
0.054870449006557465,
0.018069051206111908,
-0.06927622109651566,
0.06260430067777634,
-0.04292001947760582,
0.005189078859984875,
-0.06470969319343567,
-0.035800788551568985,
-0.01826167106628418,
-0.10580895096063614,
-0.055791351944208145,
-0.03... |
ae58358f-3fce-469a-989b-772e5ce74db4 | Examples
Convert days since year zero to dates
sql title=Query
SELECT
fromDaysSinceYearZero(739136) AS date1,
fromDaysSinceYearZero(toDaysSinceYearZero(toDate('2023-09-08'))) AS date2
response title=Response
βββββββdate1ββ¬ββββββdate2ββ
β 2023-09-08 β 2023-09-08 β
ββββββββββββββ΄βββββββββββββ
fromDaysSinceYearZer... | {"source_file": "date-time-functions.md"} | [
-0.006306370720267296,
0.04641358181834221,
-0.014563411474227905,
0.06401929259300232,
-0.10360120236873627,
-0.03764693811535835,
0.00156048231292516,
0.0637228786945343,
-0.07281437516212463,
-0.031689517199993134,
0.0009940552990883589,
-0.13704097270965576,
0.030355332419276237,
-0.00... |
af474f83-d911-4926-a630-48b2665e4db2 | fromUTCTimestamp {#fromUTCTimestamp}
Introduced in: v22.1
Converts a date or date with time value from UTC timezone to a date or date with time value with the specified time zone. This function is mainly included for compatibility with Apache Spark and similar frameworks.
Syntax
sql
fromUTCTimestamp(datetime, t... | {"source_file": "date-time-functions.md"} | [
0.0058148265816271305,
-0.0013699809787794948,
-0.03364970162510872,
0.01770772598683834,
0.022751523181796074,
-0.013655115850269794,
0.028993038460612297,
0.039426758885383606,
0.003766933223232627,
0.009237934835255146,
-0.004867365583777428,
-0.12367258965969086,
-0.07972609251737595,
... |
f01d26b6-2216-4182-ba74-2e4afc0e570a | Introduced in: v23.1
This function converts a Unix timestamp to a calendar date and a time of a day.
It can be called in two ways:
When given a single argument of type
Integer
, it returns a value of type
DateTime
, i.e. behaves like
toDateTime
.
When given two or three arguments where the first argument is ... | {"source_file": "date-time-functions.md"} | [
0.01438522431999445,
0.061267632991075516,
-0.05208491533994675,
0.015438073314726353,
0.004769227933138609,
0.01619209162890911,
0.01578289084136486,
0.07234791666269302,
0.025521857663989067,
-0.046383824199438095,
-0.0618511326611042,
-0.08069624751806259,
-0.043512776494026184,
-0.0310... |
702d11fe-c8af-4e08-b280-fb089c1a928b | Returned value
Returns a
Date32
value constructed from the provided arguments
Date32
Examples
Date32 from a year, month, day
sql title=Query
SELECT makeDate(2023, 2, 28) AS date;
response title=Response
ββββββββdateββ
β 2023-02-28 β
ββββββββββββββ
Date32 from year and day of year
sql title=Query
SELECT... | {"source_file": "date-time-functions.md"} | [
0.00618298863992095,
0.028991352766752243,
-0.04733828827738762,
0.06697218120098114,
-0.07031978666782379,
-0.06321361660957336,
0.009449897333979607,
0.010552446357905865,
-0.019504573196172714,
0.02354723960161209,
-0.023658137768507004,
-0.11350881308317184,
-0.0016079688211902976,
-0.... |
847caaed-86a3-4777-9ede-1c0e7da94746 | Syntax
sql
monthName(datetime)
Arguments
datetime
β Date or date with time.
Date
or
Date32
or
DateTime
or
DateTime64
Returned value
Returns the name of the month.
String
Examples
Get month name from date
sql title=Query
WITH toDateTime('2021-04-14 11:22:33') AS date_value
SELECT monthName(d... | {"source_file": "date-time-functions.md"} | [
0.0014540759148076177,
-0.008846884593367577,
-0.09117911756038666,
0.07028862833976746,
-0.02214450016617775,
-0.06135089322924614,
0.03892708942294121,
0.011361449025571346,
0.014896776527166367,
0.02224140428006649,
0.008865823037922382,
-0.058820631355047226,
-0.05348389968276024,
0.01... |
04474270-e98a-4877-86e5-9f0f59be85ed | Examples
Difference with the now() function
sql title=Query
SELECT
now(),
nowInBlock(),
sleep(1)
FROM numbers(3)
SETTINGS max_block_size = 1
FORMAT PrettyCompactMonoBlock
response title=Response
ββββββββββββββββnow()ββ¬ββββββββnowInBlock()ββ¬βsleep(1)ββ
β 2022-08-21 19:41:19 β 2022-08-21 19:41:19 β ... | {"source_file": "date-time-functions.md"} | [
-0.05269663780927658,
0.013550357893109322,
-0.03633493930101395,
0.07248060405254364,
0.008325599133968353,
-0.045906685292720795,
-0.0369514636695385,
0.013000545091927052,
0.036746442317962646,
0.005383637733757496,
-0.0026967802550643682,
-0.008370461873710155,
-0.06656983494758606,
-0... |
f37281bf-0857-4af6-8249-2cf34a229307 | Syntax
sql
subDate(datetime, interval)
Arguments
datetime
β The date or date with time from which
interval
is subtracted.
Date
or
Date32
or
DateTime
or
DateTime64
interval
β Interval to subtract.
Interval
Returned value
Returns date or date with time obtained by subtracting
interval
from
... | {"source_file": "date-time-functions.md"} | [
-0.02838023193180561,
0.053910840302705765,
0.003355212975293398,
0.07616601884365082,
-0.04576859995722771,
-0.04098908230662346,
0.030410699546337128,
0.044427841901779175,
-0.035818420350551605,
-0.0419258251786232,
0.0034123973455280066,
-0.12220171838998795,
0.036651451140642166,
0.03... |
eb7de984-8f2e-4ae3-b1bd-230603bacb7f | num
β Number of hours to subtract.
(U)Int*
or
Float*
Returned value
Returns
datetime
minus
num
hours
DateTime
or
DateTime64(3)
Examples
Subtract hours from different date types
sql title=Query
WITH
toDate('2024-01-01') AS date,
toDateTime('2024-01-01 00:00:00') AS date_time,
'2024-01-... | {"source_file": "date-time-functions.md"} | [
0.025545751675963402,
0.07644805312156677,
0.007447245996445417,
0.07180222123861313,
-0.009458668529987335,
-0.0790744349360466,
0.006000400520861149,
0.04063943028450012,
-0.02858281135559082,
-0.027179650962352753,
-0.03263165429234505,
-0.13808253407478333,
-0.012109755538403988,
0.020... |
3d781767-f91f-4e0c-834e-f2db06fb8b7c | Arguments
datetime
β Date with time to subtract specified number of microseconds from.
DateTime
or
DateTime64
or
String
num
β Number of microseconds to subtract.
(U)Int*
or
Float*
Returned value
Returns
datetime
minus
num
microseconds
DateTime64
Examples
Subtract microseconds from differe... | {"source_file": "date-time-functions.md"} | [
0.03842606022953987,
0.053580399602651596,
-0.022840889170765877,
0.06011911854147911,
-0.002831055549904704,
-0.039601679891347885,
0.018535159528255463,
0.08934802561998367,
0.007055919151753187,
-0.026315268129110336,
-0.018038012087345123,
-0.15169797837734222,
-0.02422134205698967,
0.... |
9fb3bca2-e731-4f1c-8deb-45533b108106 | sql
subtractMinutes(datetime, num)
Arguments
datetime
β Date or date with time to subtract specified number of minutes from.
Date
or
Date32
or
DateTime
or
DateTime64
or
String
num
β Number of minutes to subtract.
(U)Int*
or
Float*
Returned value
Returns
datetime
minus
num
minutes
DateTi... | {"source_file": "date-time-functions.md"} | [
0.04239952936768532,
0.09123259037733078,
-0.028426866978406906,
0.03910818323493004,
-0.00585523247718811,
-0.01807338371872902,
0.03643880784511566,
0.07433284819126129,
-0.009414843283593655,
-0.022626105695962906,
-0.014268007129430771,
-0.16251923143863678,
0.01355911698192358,
0.0569... |
6432ba7e-94ca-4f26-8cc7-1a8e3f2b1270 | response title=Response
ββminus(CAST('β―lMonth(10))ββ
β 1997-08-16 β
ββββββββββββββββββββββββββββ
subtractNanoseconds {#subtractNanoseconds}
Introduced in: v20.1
Subtracts a specified number of nanoseconds from a date with time or a string-encoded date with time.
Syntax
sql
subtractNanoseconds(da... | {"source_file": "date-time-functions.md"} | [
0.015675868839025497,
0.03225484490394592,
0.019604694098234177,
0.05879998579621315,
-0.01967177540063858,
-0.03338726982474327,
0.041885245591402054,
0.09269344806671143,
-0.006147786974906921,
-0.0453239381313324,
-0.023219414055347443,
-0.1490963101387024,
-0.012405543588101864,
0.0398... |
45437d9e-9a76-453c-8af1-42838ac57e4d | Using alternative INTERVAL syntax
sql title=Query
SELECT dateSub('1998-06-16'::Date, INTERVAL 10 quarter)
response title=Response
ββminus(CAST('1β―Quarter(10))ββ
β 1996-09-16 β
βββββββββββββββββββββββββββββ
subtractSeconds {#subtractSeconds}
Introduced in: v1.1
Subtracts a specified number of se... | {"source_file": "date-time-functions.md"} | [
0.008395063690841198,
0.04888876900076866,
0.0006442857556976378,
0.039095569401979446,
-0.04402228444814682,
0.002340540988370776,
0.031619906425476074,
0.08587145805358887,
0.008523805066943169,
-0.07953473180532455,
0.004777114372700453,
-0.11912615597248077,
0.0006864677416160703,
0.02... |
b09e3fa4-91cf-47f5-bd54-258bab80dcdb | Syntax
sql
subtractWeeks(datetime, num)
Arguments
datetime
β Date or date with time to subtract specified number of weeks from.
Date
or
Date32
or
DateTime
or
DateTime64
or
String
num
β Number of weeks to subtract.
(U)Int*
or
Float*
Returned value
Returns
datetime
minus
num
weeks
Date
... | {"source_file": "date-time-functions.md"} | [
0.014847608283162117,
0.06611235439777374,
-0.010978990234434605,
0.057315461337566376,
0.005171583499759436,
0.042074013501405716,
-0.014546862803399563,
0.04121873900294304,
-0.11573445796966553,
-0.02383050136268139,
-0.029721565544605255,
-0.13935670256614685,
-0.007141225505620241,
-0... |
a6d01daf-1e63-4333-9530-a86b84013f35 | response title=Response
ββminus(CAST('β―alYear(10))ββ
β 1988-06-16 β
ββββββββββββββββββββββββββββ
timeDiff {#timeDiff}
Introduced in: v23.4
Returns the difference between two dates or dates with time values in seconds.
The difference is calculated as
enddate
-
startdate
.
This function is equiva... | {"source_file": "date-time-functions.md"} | [
-0.00010361836029915139,
0.04664349928498268,
0.0033215621951967478,
0.019822319969534874,
-0.00871471967548132,
0.0073036570101976395,
-0.016291210427880287,
0.07107895612716675,
0.02692483738064766,
-0.03956473246216774,
0.03498972952365875,
-0.14100487530231476,
0.0028346756007522345,
0... |
304afbf5-2106-4daf-9d87-7cbda774c394 | timeSlots {#timeSlots}
Introduced in: v1.1
For a time interval starting at
StartTime
and continuing for
Duration
seconds, it returns an array of moments in time, consisting of points from this interval rounded down to the
Size
in seconds.
Size
is an optional parameter set to 1800 (30 minutes) by default.
... | {"source_file": "date-time-functions.md"} | [
0.02572571113705635,
-0.016745546832680702,
-0.07768868654966354,
-0.003634774126112461,
-0.04488002508878708,
0.018309229984879494,
0.011298066936433315,
0.09135494381189346,
0.024905318394303322,
0.0013325868640094995,
0.020728975534439087,
-0.05358630791306496,
-0.02621060609817505,
0.0... |
be759df9-bf57-44c7-8263-5a71fdf6624b | response title=Response
ββββββββββββββββββββββββββtsββ
β 2023-12-31 00:00:00.000000 β
ββββββββββββββββββββββββββββββ
Add time to date string
sql title=Query
SELECT timestamp('2023-12-31 12:00:00', '12:00:00.11') AS ts;
response title=Response
ββββββββββββββββββββββββββtsββ
β 2024-01-01 00:00:00.110000 β
βββββββββ... | {"source_file": "date-time-functions.md"} | [
0.017070747911930084,
-0.008189239539206028,
-0.04658303037285805,
0.0018438758561387658,
-0.010555503889918327,
-0.0522766187787056,
0.03775545954704285,
0.04790959879755974,
0.018115166574716568,
0.024692991748452187,
-0.04723048582673073,
-0.08278413116931915,
-0.06143336370587349,
0.02... |
bf96c9b4-f3f0-4485-9f89-5b3456f0f806 | Returned value
Returns the day of the month of the given date/time
UInt8
Examples
Usage example
sql title=Query
SELECT toDayOfMonth(toDateTime('2023-04-21 10:20:30'))
response title=Response
ββtoDayOfMonth(toDateTime('2023-04-21 10:20:30'))ββ
β 21 β
ββββββββββββββ... | {"source_file": "date-time-functions.md"} | [
-0.0519254133105278,
0.041106875985860825,
0.0070280758664011955,
0.07630767673254013,
-0.06836546957492828,
0.031208839267492294,
-0.0015139702009037137,
0.00877651758491993,
-0.06073726341128349,
-0.05994904413819313,
-0.006669522728770971,
-0.1011846587061882,
-0.028523821383714676,
-0.... |
4e4948f7-e315-4a9f-a458-428c2df6d0a0 | toDaysSinceYearZero {#toDaysSinceYearZero}
Introduced in: v23.9
For a given date, returns the number of days which have passed since
1 January 0000
in the
proleptic Gregorian calendar defined by ISO 8601
.
The calculation is the same as in MySQL's
TO_DAYS
function.
Syntax
sql
toDaysSinceYearZero(date[, t... | {"source_file": "date-time-functions.md"} | [
-0.014334439300000668,
0.048482608050107956,
-0.02902427688241005,
0.06449875980615616,
-0.08333580195903778,
-0.027855295687913895,
-0.010303845629096031,
0.0454806387424469,
-0.05248846113681793,
-0.012522413395345211,
0.004221740644425154,
-0.16451643407344818,
-0.0035916820634156466,
0... |
da4633d8-6a34-4141-b89a-9319e1727756 | toLastDayOfWeek {#toLastDayOfWeek}
Introduced in: v23.5
Rounds a date or date with time up to the nearest Saturday or Sunday.
:::note
The return type can be configured by setting
enable_extended_results_for_datetime_functions
.
:::
Syntax
sql
toLastDayOfWeek(datetime[, mode[, timezone]])
Arguments
date... | {"source_file": "date-time-functions.md"} | [
-0.036575768142938614,
0.0368829183280468,
-0.019353289157152176,
0.03164699673652649,
-0.04742330312728882,
0.035230547189712524,
0.01319931447505951,
0.017306214198470116,
-0.06087370961904526,
-0.031046533957123756,
-0.05979471653699875,
-0.06695105880498886,
-0.06829631328582764,
-0.02... |
f79fdbf3-5c3a-440d-8859-0fb0e6fe9727 | toModifiedJulianDay {#toModifiedJulianDay}
Introduced in: v21.1
Converts a
Proleptic Gregorian calendar
date in text form
YYYY-MM-DD
to a
Modified Julian Day
number in
Int32
. This function supports date from
0000-01-01
to
9999-12-31
. It raises an exception if the argument cannot be parsed as a date, or ... | {"source_file": "date-time-functions.md"} | [
-0.021661249920725822,
0.07158597558736801,
0.029685838147997856,
0.010961240157485008,
-0.07988536357879639,
-0.03584814444184303,
-0.0029393858276307583,
0.024373263120651245,
-0.08329884707927704,
-0.03608180582523346,
0.018548812717199326,
-0.09297018498182297,
0.058335959911346436,
-0... |
0a02fb56-adfc-4012-a960-1b8c35b67b36 | Returned value
Returns the month of the given date/time
UInt8
Examples
Usage example
sql title=Query
SELECT toMonth(toDateTime('2023-04-21 10:20:30'))
response title=Response
ββtoMonth(toDateTime('2023-04-21 10:20:30'))ββ
β 4 β
ββββββββββββββββββββββββββββββββββββββββ... | {"source_file": "date-time-functions.md"} | [
-0.02441779337823391,
0.01141499076038599,
-0.024891076609492302,
0.030603952705860138,
-0.07985600084066391,
0.023492783308029175,
-0.0327555276453495,
-0.007572971284389496,
0.008074234239757061,
0.012267319485545158,
0.030348576605319977,
-0.09568823873996735,
0.01214898657053709,
0.003... |
793bbbb5-9746-4ad2-99e8-9abdd8e1dc00 | Syntax
sql
toRelativeHourNum(date)
Arguments
date
β Date or date with time.
Date
or
DateTime
or
DateTime64
Returned value
Returns the number of hours from a fixed reference point in the past.
UInt32
Examples
Get relative hour numbers
sql title=Query
SELECT toRelativeHourNum(toDateTime('2023-0... | {"source_file": "date-time-functions.md"} | [
-0.05100319907069206,
0.0491853803396225,
0.00987771712243557,
0.05325895547866821,
-0.07341738790273666,
-0.035752203315496445,
0.0021824645809829235,
0.10572898387908936,
-0.006743560545146465,
-0.017041759565472603,
-0.03378066420555115,
-0.06804917007684708,
-0.010026584379374981,
-0.0... |
0ce2d847-b793-444f-80ee-d80724790f20 | Syntax
sql
toRelativeQuarterNum(date)
Arguments
date
β Date or date with time.
Date
or
DateTime
or
DateTime64
Returned value
Returns the number of quarters from a fixed reference point in the past.
UInt32
Examples
Get relative quarter numbers
sql title=Query
SELECT toRelativeQuarterNum(toDate... | {"source_file": "date-time-functions.md"} | [
-0.050822220742702484,
0.04055663198232651,
-0.024766769260168076,
0.020203053951263428,
-0.0890980213880539,
0.03041168674826622,
-0.025285186246037483,
0.09322966635227203,
0.001137713436037302,
-0.015205031260848045,
0.004973205272108316,
-0.0827600359916687,
-0.022642478346824646,
-0.0... |
967e7ca2-4aca-4875-8584-d9a3b1817074 | Syntax
sql
toRelativeYearNum(date)
Arguments
date
β Date or date with time.
Date
or
DateTime
or
DateTime64
Returned value
Returns the number of years from a fixed reference point in the past.
UInt16
Examples
Get relative year numbers
sql title=Query
SELECT toRelativeYearNum('2010-10-01'::Date... | {"source_file": "date-time-functions.md"} | [
-0.043018221855163574,
-0.021702392026782036,
-0.013588584959506989,
0.04587874189019203,
-0.05841641128063202,
0.0605025514960289,
0.01191167626529932,
0.06461227685213089,
0.000601276580709964,
-0.030713742598891258,
0.01531720720231533,
-0.07118500769138336,
-0.009695261716842651,
0.033... |
103a1bfd-e2ab-47da-8333-ee730f6ea36e | toStartOfFiveMinutes {#toStartOfFiveMinutes}
Introduced in: v22.6
Rounds down a date with time to the start of the nearest five-minute interval.
:::note
The return type can be configured by setting
enable_extended_results_for_datetime_functions
.
:::
Syntax
sql
toStartOfFiveMinutes(datetime)
Aliases
:
toS... | {"source_file": "date-time-functions.md"} | [
-0.020999256521463394,
0.022412655875086784,
-0.02299097739160061,
0.04823417589068413,
0.021007318049669266,
0.06203616410493851,
-0.017430707812309265,
0.0658092126250267,
0.015111129730939865,
0.02529127709567547,
-0.0703500360250473,
-0.07765369862318039,
-0.021647315472364426,
0.00632... |
2daa5906-5e60-4392-b05d-aa0e6129ebda | Introduced in: v20.1
This function generalizes other
toStartOf*()
functions with
toStartOfInterval(date_or_date_with_time, INTERVAL x unit [, time_zone])
syntax.
For example,
-
toStartOfInterval(t, INTERVAL 1 YEAR)
returns the same as
toStartOfYear(t)
,
-
toStartOfInterval(t, INTERVAL 1 MONTH)
returns the ... | {"source_file": "date-time-functions.md"} | [
0.002934260293841362,
-0.0031967395916581154,
-0.030693145468831062,
0.025626298040151596,
0.0023446381092071533,
0.050892554223537445,
-0.060642581433057785,
0.03864693641662598,
-0.015359589830040932,
0.017642751336097717,
-0.028797069564461708,
-0.07025299221277237,
0.03562237694859505,
... |
656bbb06-db87-4615-b879-f07cab7d6c6a | toStartOfMicrosecond {#toStartOfMicrosecond}
Introduced in: v22.6
Rounds down a date with time to the start of the microseconds.
Syntax
sql
toStartOfMicrosecond(datetime, [timezone])
Arguments
datetime
β Date and time.
DateTime64
timezone
β Optional. Timezone for the returned value. If not specified,... | {"source_file": "date-time-functions.md"} | [
0.037447210401296616,
-0.003903592238202691,
-0.07141346484422684,
0.04010865092277527,
-0.0022863205522298813,
0.04074116051197052,
0.009186451323330402,
0.04060368239879608,
-0.0012372725177556276,
0.02908993698656559,
-0.06300371885299683,
-0.11001815646886826,
-0.01824033260345459,
-0.... |
c06ca035-9145-4315-a72b-d27fb25b3e30 | toStartOfMonth {#toStartOfMonth}
Introduced in: v1.1
Rounds down a date or date with time to the first day of the month.
:::note
The return type can be configured by setting
enable_extended_results_for_datetime_functions
.
:::
Syntax
sql
toStartOfMonth(value)
Arguments
value
β The date or date with ti... | {"source_file": "date-time-functions.md"} | [
0.0015363090205937624,
-0.022708173841238022,
-0.06542889028787613,
0.07577752321958542,
-0.012766492553055286,
0.014650357887148857,
0.027411097660660744,
0.051562901586294174,
-0.030106887221336365,
0.05591818690299988,
-0.05396026372909546,
-0.06524427980184555,
0.0019688978791236877,
-... |
39c33534-9773-4d89-a012-9b5ad3545622 | toStartOfSecond {#toStartOfSecond}
Introduced in: v20.5
Rounds down a date with time to the start of the seconds.
Syntax
sql
toStartOfSecond(datetime, [timezone])
Arguments
datetime
β Date and time to truncate sub-seconds from.
DateTime64
timezone
β Optional. Timezone for the returned value. If not s... | {"source_file": "date-time-functions.md"} | [
0.057412441819906235,
0.002931508468464017,
-0.06978625059127808,
0.04290473088622093,
-0.010050665587186813,
-0.013109191320836544,
0.007922378368675709,
0.023581573739647865,
0.028395602479577065,
0.028256896883249283,
-0.06613407284021378,
-0.08796233683824539,
-0.02174883894622326,
-0.... |
886595d8-8994-4248-828c-e282fce0ffd2 | Examples
Round down to the nearest Sunday or Monday
sql title=Query
SELECT
toStartOfWeek(toDateTime('2023-04-21 10:20:30')), /* a Friday */
toStartOfWeek(toDateTime('2023-04-21 10:20:30'), 1), /* a Friday */
toStartOfWeek(toDate('2023-04-24')), /* a Monday */
toStartOfWeek(toDate('20... | {"source_file": "date-time-functions.md"} | [
-0.017932450398802757,
0.04561549052596092,
0.025646282359957695,
0.024569213390350342,
-0.02373986691236496,
0.059589557349681854,
-0.07275570183992386,
-0.006546495482325554,
-0.0386042483150959,
-0.021315651014447212,
-0.06940220296382904,
-0.06371065229177475,
-0.027602821588516235,
-0... |
4fda59d6-0f3e-4ac9-bb8b-8da7c00b3015 | Syntax
sql
toTimeZone(datetime, timezone)
Aliases
:
toTimeZone
Arguments
date
β The value to convert.
DateTime
or
DateTime64
timezone
β The target time zone name.
String
Returned value
Returns the same timestamp as the input, but with the specified time zone
DateTime
or
DateTime64
Examples... | {"source_file": "date-time-functions.md"} | [
0.043776411563158035,
0.008535152301192284,
-0.05128169059753418,
0.018761519342660904,
-0.01167435571551323,
-0.07461915910243988,
0.043126992881298065,
0.057025130838155746,
-0.029357872903347015,
0.005912184249609709,
-0.036806099116802216,
-0.14757093787193298,
-0.006462428718805313,
0... |
f5ff0d7e-c3d3-4b18-bb6c-2350aa46ea22 | response title=Response
Row 1:
ββββββ
dt_str: 2017-11-05 08:07:47
from_str: 1509869267
from_str_tokyo: 1509836867
from_datetime: 1509869267
from_datetime64: 1509869267
from_date: 1509840000
from_date32: 1509840000
toWeek {#toWeek}
Introduced in: v20.1
This function returns the week nu... | {"source_file": "date-time-functions.md"} | [
-0.07256459444761276,
0.057260408997535706,
-0.007688107900321484,
0.041229497641325,
-0.05438372492790222,
0.0283189807087183,
-0.06511648744344711,
0.022548014298081398,
-0.09875648468732834,
-0.05486297979950905,
-0.016788378357887268,
-0.10402237623929977,
-0.06652381271123886,
-0.0038... |
fe39e593-a84c-4f83-8b27-e3fab6a2c2c2 | Returned value
Returns the week number according to the specified mode.
UInt32
Examples
Get week numbers with different modes
sql title=Query
SELECT toDate('2016-12-27') AS date, toWeek(date) AS week0, toWeek(date,1) AS week1, toWeek(date,9) AS week9
response title=Response
ββββββββdateββ¬βweek0ββ¬βweek1ββ¬βwee... | {"source_file": "date-time-functions.md"} | [
0.02008979022502899,
0.002098512602970004,
-0.02103409916162491,
0.02453719638288021,
-0.06741909682750702,
0.035197146236896515,
0.0478786937892437,
0.032160647213459015,
-0.14021578431129456,
-0.039204422384500504,
-0.031794607639312744,
-0.09464360028505325,
-0.01940583623945713,
0.0051... |
0c0ae273-b130-47af-bc27-6ca7e86a9f09 | timezone
β Optional. Timezone for the conversion. If provided, the timezone must be a string constant.
String
Returned value
Returns a
UInt64
number containing the year, month, day, hour, minute and second (YYYY * 10000000000 + MM * 100000000 + DD * 1000000 + hh * 10000 + mm * 100 + ss).
UInt64
Examples
... | {"source_file": "date-time-functions.md"} | [
0.04167556390166283,
0.007088780403137207,
-0.01852325163781643,
0.011057153344154358,
-0.027821633964776993,
-0.019749417901039124,
0.005403244402259588,
0.04062803089618683,
-0.04359808936715126,
0.0017001728992909193,
-0.016792098060250282,
-0.10633471608161926,
-0.013390596956014633,
0... |
c3342ab2-adf5-40d5-ba53-e69e3898bd90 | mode
β Optional. A mode
0
to
9
determines the first day of the week and the range of the week number. Default
0
. -
timezone
β Optional. Time zone.
String
Returned value
Returns year and week number as a combined integer value.
UInt32
Examples
Get year-week combinations with different modes
sql ti... | {"source_file": "date-time-functions.md"} | [
-0.024053962901234627,
0.018722357228398323,
-0.034866414964199066,
0.05630795657634735,
-0.039468735456466675,
0.03349420428276062,
0.018037427216768265,
-0.0004988079308532178,
-0.09695955365896225,
-0.036428920924663544,
-0.04710030183196068,
-0.10284887999296188,
-0.07719756662845612,
... |
4fb387ba-8c5a-4082-8be6-944f93dcb9b0 | description: 'Documentation for logical functions'
sidebar_label: 'Logical'
slug: /sql-reference/functions/logical-functions
title: 'Logical functions'
doc_type: 'reference'
Logical functions
The functions below perform logical operations on arguments of arbitrary numeric types.
They return either
0
or
1
as
... | {"source_file": "logical-functions.md"} | [
0.04224082827568054,
0.046910181641578674,
0.0010955241741612554,
-0.0037165090907365084,
-0.034459326416254044,
-0.010629258118569851,
0.04935045540332794,
0.030329374596476555,
-0.03388874977827072,
-0.012356891296803951,
0.030753472819924355,
-0.020899467170238495,
0.06451362371444702,
... |
8161bc6c-2203-451a-9de3-0edb8f1c7ab6 | -
0
, if all arguments evaluate to
false
-
NULL
, if all arguments evaluate to
false
and at least one argument is
NULL
Nullable(UInt8)
Examples
Basic usage
sql title=Query
SELECT or(1, 0, 0, 2, NULL);
response title=Response
1
With NULL
sql title=Query
SELECT or(0, NULL);
response title=Response
... | {"source_file": "logical-functions.md"} | [
-0.007236242759972811,
0.016791239380836487,
-0.09776285290718079,
-0.021058276295661926,
-0.025936154648661613,
-0.07337458431720734,
0.08694835752248764,
-0.014027828350663185,
-0.028796346858143806,
-0.07132093608379364,
0.04608717933297157,
-0.07603892683982849,
0.07235869020223618,
0.... |
090c698d-bb1a-446a-8af1-68a7701952bc | description: 'Documentation for rounding functions'
sidebar_label: 'Rounding'
slug: /sql-reference/functions/rounding-functions
title: 'Rounding functions'
doc_type: 'reference'
Rounding functions
:::note
The documentation below is generated from the
system.functions
system table
:::
ceil {#ceil}
Introd... | {"source_file": "rounding-functions.md"} | [
-0.023101964965462685,
0.02719016931951046,
-0.038799360394477844,
-0.008662614040076733,
-0.057595252990722656,
-0.11160261929035187,
-0.00019349496869836003,
0.11506547778844833,
0.031155234202742577,
-0.009620722383260727,
0.00945601798593998,
-0.08663800358772278,
0.04906954988837242,
... |
1e871b28-d4d5-4cfe-abc9-3821ac2095bf | If rounding causes an overflow (for example,
round(255, -1)
), the result is undefined.
Syntax
sql
round(x[, N])
Arguments
x
β A number to round.
Float*
or
Decimal*
or
(U)Int*
N
β Optional. The number of decimal places to round to. Defaults to
0
.
(U)Int*
Returned value
Returns a rounded num... | {"source_file": "rounding-functions.md"} | [
0.008350174874067307,
0.034796569496393204,
-0.040253013372421265,
-0.0005004857666790485,
-0.051132600754499435,
-0.0769432783126831,
0.04539016634225845,
0.07584597915410995,
-0.0332799069583416,
-0.022701501846313477,
-0.055231936275959015,
-0.09895191341638565,
-0.034572578966617584,
-... |
a5364461-ca5e-432e-b967-5f480f416d99 | :::tip Use banker's rounding for summation or subtraction of numbers
Using banker's rounding, you can reduce the effect that rounding numbers has on the results of summing or subtracting these numbers.
For example, sum numbers
1.5, 2.5, 3.5, 4.5
with different rounding:
- No rounding:
1.5 + 2.5 + 3.5 + 4.5 = 12
.
... | {"source_file": "rounding-functions.md"} | [
0.01934225857257843,
0.01618197374045849,
-0.06463637948036194,
-0.02548239752650261,
-0.06736572086811066,
-0.09257417917251587,
0.0905814841389656,
0.050870876759290695,
0.021658841520547867,
-0.025143666192889214,
-0.03569644317030907,
-0.10179682821035385,
-0.0223957858979702,
-0.06342... |
d524abe4-0d23-47ed-abaf-1f03f9489a52 | Examples
Usage example
sql title=Query
SELECT *, roundDuration(*) FROM system.numbers WHERE number IN (0, 9, 19, 47, 101, 149, 205, 271, 421, 789, 1423, 2345, 4567, 9876, 24680, 42573)
response title=Response
ββnumberββ¬βroundDuration(number)ββ
β 0 β 0 β
β 9 β 1 β
... | {"source_file": "rounding-functions.md"} | [
-0.012779678218066692,
0.05036540329456329,
-0.05499189719557762,
0.01789233461022377,
-0.028467202559113503,
-0.05151400715112686,
0.0863180011510849,
0.05810900777578354,
0.0021424058359116316,
-0.006120692938566208,
-0.04057885333895683,
-0.09222086519002914,
0.056284308433532715,
-0.04... |
425eb7b2-507d-4c39-ba9f-4b558ad6fc55 | description: 'Documentation for uniqTheta Functions'
sidebar_label: 'uniqTheta'
slug: /sql-reference/functions/uniqtheta-functions
title: 'uniqTheta Functions'
doc_type: 'reference'
uniqTheta functions
uniqTheta functions work for two uniqThetaSketch objects to do set operation calculations such as βͺ / β© / Γ (un... | {"source_file": "uniqtheta-functions.md"} | [
-0.06401417404413223,
-0.011028498411178589,
-0.03251224011182785,
0.03194563090801239,
-0.12210611253976822,
0.00007481616194127128,
0.07451880723237991,
-0.051580049097537994,
-0.02250460535287857,
-0.0017084864666685462,
-0.03384232893586159,
-0.03345621004700661,
0.0801263153553009,
-0... |
0255f0a1-660a-4d5e-b955-0395ac654993 | description: 'Documentation for distance functions'
sidebar_label: 'Distance'
slug: /sql-reference/functions/distance-functions
title: 'Distance functions'
keywords: ['distance functions', 'norms', 'distances', 'vectors']
doc_type: 'reference'
Distance functions
L1Distance {#L1Distance}
Introduced in: v21.1... | {"source_file": "distance-functions.md"} | [
-0.021391700953245163,
-0.05471267178654671,
-0.04310782253742218,
-0.023194612935185432,
-0.04060984402894974,
0.002970599103718996,
0.03516456484794617,
0.07354656606912613,
-0.06469116359949112,
-0.03721077740192413,
0.054072048515081406,
-0.04630890116095543,
0.05106232315301895,
-0.05... |
71291d07-d4ad-4750-ae5f-9e2a399403f9 | Syntax
sql
L2DistanceTransposed(vector1, vector2, p)
Aliases
:
distanceL2Transposed
Arguments
vectors
β Vectors.
QBit(T, UInt64)
reference
β Reference vector.
Array(T)
p
β Number of bits from each vector element to use in the distance calculation (1 to element bit-width). The quantization level cont... | {"source_file": "distance-functions.md"} | [
0.019660744816064835,
0.0006664709071628749,
-0.06823539733886719,
-0.034065667539834976,
-0.019299879670143127,
-0.04131413996219635,
-0.035180311650037766,
0.033610690385103226,
0.019418537616729736,
-0.07548714429140091,
0.008632860146462917,
-0.08324402570724487,
0.06221422180533409,
-... |
4deec113-b7c8-4605-a6e9-3710690d164d | Calculates the square root of the sum of the squares of the vector elements (the
L2Norm
) squared.
Syntax
sql
L2SquaredNorm(vector)
Aliases
:
normL2Squared
Arguments
vector
β Vector or tuple of numeric values.
Array(T)
or
Tuple(T)
Returned value
Returns the L2-norm squared.
UInt*
or
Float*
o... | {"source_file": "distance-functions.md"} | [
0.010973620228469372,
-0.10191211849451065,
-0.03798381984233856,
-0.02117534540593624,
0.05408795550465584,
-0.014915704727172852,
-0.015355944633483887,
0.06610426306724548,
-0.029658613726496696,
-0.02020840160548687,
0.05605832487344742,
0.006355357822030783,
0.03647328540682793,
-0.02... |
de510cfb-30be-4bcf-8a7b-76307fd46e92 | response title=Response
ββLpDistance((1, 2), (2, 3), 3)ββ
β 1.2599210498948732 β
βββββββββββββββββββββββββββββββββ
LpNorm {#LpNorm}
Introduced in: v21.11
Calculates the p-norm of a vector, which is the p-th root of the sum of the p-th powers of the absolute elements of its elements.
Special cases:
- ... | {"source_file": "distance-functions.md"} | [
0.019467845559120178,
-0.06310978531837463,
-0.06909771263599396,
-0.0010477494215592742,
0.02195177786052227,
-0.04825340956449509,
0.07041164487600327,
0.06255090981721878,
-0.023171233013272285,
-0.008695784024894238,
0.028631549328565598,
-0.004219538066536188,
0.061498720198869705,
-0... |
37d2194b-214e-4c6c-8618-d4ea5991c5b3 | description: 'Documentation for Bitmap Functions'
sidebar_label: 'Bitmap'
slug: /sql-reference/functions/bitmap-functions
title: 'Bitmap Functions'
doc_type: 'reference'
Bitmap functions
Bitmaps can be constructed in two ways. The first way is constructed by aggregation function groupBitmap with
-State
, the oth... | {"source_file": "bitmap-functions.md"} | [
0.001544386032037437,
0.03763844445347786,
0.016320349648594856,
0.010768870823085308,
-0.06054021418094635,
-0.02100360579788685,
0.08335711807012558,
-0.03605777025222778,
-0.10049253702163696,
0.0019943476654589176,
-0.014033050276339054,
-0.1228938028216362,
0.08661749958992004,
-0.021... |
21d192a4-ad91-463b-99dd-f3a87e024d2e | response title=Response
ββresββ
β 2 β
βββββββ
bitmapBuild {#bitmapBuild}
Introduced in: v20.1
Builds a bitmap from an unsigned integer array. It is the opposite of function
bitmapToArray
.
Syntax
sql
bitmapBuild(array)
Arguments
array
β Unsigned integer array.
Array(UInt*)
Returned value
Retu... | {"source_file": "bitmap-functions.md"} | [
0.03136022016406059,
0.0654958188533783,
-0.007129282224923372,
0.033280570060014725,
-0.04601944610476494,
-0.041274163872003555,
0.0635882019996643,
-0.02413005381822586,
-0.06142839044332504,
-0.012327647767961025,
-0.047232870012521744,
-0.1212407797574997,
0.06576443463563919,
-0.0309... |
b466ffa9-2bb6-4e3a-8398-ad916c83ac58 | Examples
Usage example
sql title=Query
SELECT bitmapHasAny(bitmapBuild([1, 2, 3]), bitmapBuild([3, 4, 5])) AS res;
response title=Response
ββresββ
β 1 β
βββββββ
bitmapMax {#bitmapMax}
Introduced in: v20.1
Returns the position of the greatest bit set in a bitmap, or
0
if the bitmap is empty.
Syntax
s... | {"source_file": "bitmap-functions.md"} | [
0.02904268354177475,
0.050562936812639236,
-0.024522826075553894,
0.007378250826150179,
-0.05018312856554985,
-0.043222080916166306,
0.044732727110385895,
0.02177065797150135,
-0.04705885425209999,
0.024225803092122078,
-0.03639786317944527,
-0.05804499611258507,
0.0728011503815651,
-0.055... |
3c1bfd26-c686-4592-8e58-4a6fcfcab7b1 | Returned value
Returns a bitmap containing only the set bits in the specified range
AggregateFunction(groupBitmap, T)
Examples
Usage example
sql title=Query
SELECT bitmapToArray(bitmapSubsetInRange(bitmapBuild([1, 2, 3, 4, 5]), 2, 5)) AS res;
response title=Response
ββresββββββββ
β [2, 3, 4] β
βββββββββββββ
... | {"source_file": "bitmap-functions.md"} | [
0.023673677816987038,
0.06219221651554108,
-0.020960690453648567,
0.03989079222083092,
-0.03108057752251625,
-0.03423832729458809,
0.046816617250442505,
-0.017400886863470078,
-0.05546100065112114,
-0.03489643335342407,
-0.06430353224277496,
-0.10410185903310776,
0.048344168812036514,
-0.0... |
d0394a2a-025d-48cc-b14e-f6dbf30796ff | Returned value
Returns a bitmap containing set bits present in either input bitmap, but not in both
AggregateFunction(groupBitmap, T)
Examples
Usage example
sql title=Query
SELECT bitmapToArray(bitmapXor(bitmapBuild([1, 2, 3]), bitmapBuild([3, 4, 5]))) AS res;
response title=Response
ββresβββββββββββ
β [1, 2... | {"source_file": "bitmap-functions.md"} | [
-0.0019378813449293375,
0.016107749193906784,
0.03499186038970947,
0.02796543575823307,
-0.04663431644439697,
-0.07164647430181503,
0.04361053183674812,
-0.003311438485980034,
-0.03440423309803009,
-0.038695983588695526,
-0.017337948083877563,
-0.11693795025348663,
0.08174263685941696,
-0.... |
9dad15bf-8e12-483b-b03c-4d4f68b637a1 | description: 'Documentation for mathematical functions'
sidebar_label: 'Mathematical'
slug: /sql-reference/functions/math-functions
title: 'Mathematical functions'
doc_type: 'reference'
Mathematical functions
acos {#acos}
Introduced in: v1.1
Returns the arc cosine of the argument.
Syntax
sql
acos(x)
... | {"source_file": "math-functions.md"} | [
-0.06065808981657028,
0.026182089000940323,
-0.05730070173740387,
0.01853831298649311,
-0.03341323882341385,
-0.06508610397577286,
0.03431875258684158,
0.09434566646814346,
0.031306181102991104,
0.01419853512197733,
0.11071429401636124,
-0.07310492545366287,
0.04350595921278,
-0.0427967235... |
15ed53b6-8b54-4d98-a096-b666f8ea4366 | x
β x-coordinate of the point through which the ray passes.
(U)Int*
or
Float*
or
Decimal*
Returned value
Returns the angle
ΞΈ
such that
-Ο < ΞΈ β€ Ο
, in radians
Float64
Examples
Usage example
sql title=Query
SELECT atan2(1, 1)
response title=Response
0.7853981633974483
atanh {#atanh}
Introduce... | {"source_file": "math-functions.md"} | [
0.011060836724936962,
-0.02679447829723358,
-0.08477561175823212,
-0.005754576995968819,
-0.011327962391078472,
-0.06663874536752701,
0.03520709276199341,
0.020553776994347572,
0.014931634068489075,
-0.008967793546617031,
0.0673779770731926,
-0.09523855894804001,
0.10011423379182816,
-0.02... |
db498966-277d-4ac1-a391-3a184295cdcb | Returned value
Returns the error function value
Float*
Examples
Three sigma rule
sql title=Query
SELECT erf(3 / sqrt(2))
response title=Response
ββerf(divide(3, sqrt(2)))ββ
β 0.9973002039367398 β
βββββββββββββββββββββββββββ
erfc {#erfc}
Introduced in: v1.1
Returns a number close to
1-erf(x)
with... | {"source_file": "math-functions.md"} | [
0.017582012340426445,
-0.023611683398485184,
-0.03690463304519653,
0.04155110567808151,
0.02604818157851696,
-0.08167993277311325,
0.06753714382648468,
0.08334937691688538,
0.046275604516267776,
0.016569986939430237,
0.02703981287777424,
-0.12914283573627472,
-0.0026313455309718847,
0.0039... |
47347810-9a5d-4b3b-abda-9dd4ed831921 | Examples
Basic usage
sql title=Query
SELECT hypot(1, 1)
response title=Response
1.4142135623730951
intExp10 {#intExp10}
Introduced in: v1.1
Like
exp10
but returns a
UInt64
number.
Syntax
sql
intExp10(x)
Arguments
x
β The exponent.
Int*
or
UInt*
or
Float*
Returned value
Returns 10^x... | {"source_file": "math-functions.md"} | [
-0.027346154674887657,
-0.0022164671681821346,
-0.03068612515926361,
0.00688824150711298,
-0.05896300449967384,
-0.05993719398975372,
0.06636670231819153,
0.09404638409614563,
-0.02210809290409088,
-0.043000344187021255,
0.005969694349914789,
-0.05138763412833214,
0.058643896132707596,
-0.... |
87232b0b-33e2-4403-bd84-55ab37bf5456 | pi {#pi}
Introduced in: v1.1
Returns pi (Ο).
Syntax
sql
pi()
Arguments
None.
Returned value
Returns pi
Float64
Examples
Usage example
sql title=Query
SELECT pi();
response title=Response
3.141592653589793
pow {#pow}
Introduced in: v1.1
Returns x raised to the power of y.
Syntax
sq... | {"source_file": "math-functions.md"} | [
-0.02265975996851921,
0.02947486750781536,
-0.12080655992031097,
0.08284429460763931,
-0.04253290221095085,
-0.08169002830982208,
0.01569487527012825,
0.04877234622836113,
0.04825650528073311,
0.0237942673265934,
0.0004634522774722427,
-0.04582292214035988,
0.06851400434970856,
-0.00175333... |
1205d504-e73c-44bd-964d-e8ad2b9a0cbe | Examples
Usage example
sql title=Query
SELECT tan(0);
response title=Response
0
tanh {#tanh}
Introduced in: v20.1
Returns the hyperbolic tangent.
Syntax
sql
tanh(x)
Arguments
x
β The angle in radians. Values from the interval: -β < x < +β.
(U)Int*
or
Float*
or
Decimal*
Returned value
R... | {"source_file": "math-functions.md"} | [
-0.01349561382085085,
0.045523691922426224,
-0.02841133438050747,
-0.001318279537372291,
-0.08325168490409851,
-0.030272789299488068,
0.05980300530791283,
0.06609330326318741,
0.024059157818555832,
-0.008149764500558376,
0.035285498946905136,
-0.0833977535367012,
0.04439574107527733,
-0.02... |
f253751f-840b-4691-81f2-33611c3e76d5 | description: 'Documentation for encryption functions'
sidebar_label: 'Encryption'
slug: /sql-reference/functions/encryption-functions
title: 'Encryption functions'
keywords: ['encryption', 'regular functions', 'encrypt', 'decrypt']
doc_type: 'reference'
Encryption functions
These functions implement encryption an... | {"source_file": "encryption-functions.md"} | [
0.006080928258597851,
0.02088582143187523,
-0.03003426268696785,
-0.03201252594590187,
-0.0373757965862751,
-0.06062067672610283,
0.04572991281747818,
0.05287940055131912,
0.0000788721299613826,
-0.009320665150880814,
-0.013883738778531551,
0.018363935872912407,
0.111976757645607,
-0.01164... |
095084fc-64f4-41b9-8684-f08f98157557 | Syntax
sql
aes_encrypt_mysql(mode, plaintext, key[, iv])
Arguments
mode
β Encryption mode.
String
plaintext
β Text that should be encrypted.
String
key
β Encryption key. If the key is longer than required by
mode
, MySQL-specific key folding is performed.
String
iv
β Optional. Initialization vecto... | {"source_file": "encryption-functions.md"} | [
0.009892638772726059,
0.021952757611870766,
-0.026133188977837563,
0.02039947174489498,
-0.03535610809922218,
-0.06850012391805649,
0.09214790165424347,
0.04822712764143944,
-0.025710921734571457,
-0.012062063440680504,
-0.012519086711108685,
-0.06345286965370178,
0.12964190542697906,
-0.0... |
8962258a-ea8c-468c-954d-d7943bbcb6dc | Returned value
Returns decrypted plaintext.
String
Examples
Correctly decrypting encrypted data
sql title=Query
-- Re-using the table from the encrypt function example
SELECT comment, hex(secret) FROM encryption_test;
response title=Response
ββcommentβββββββββββββββ¬βhex(secret)βββββββββββββββββββββββββββββββ... | {"source_file": "encryption-functions.md"} | [
-0.03868672251701355,
-0.0007912039291113615,
-0.018104102462530136,
0.014878925867378712,
-0.05288020521402359,
-0.06258777529001236,
0.09613575786352158,
-0.010078039951622486,
0.017529785633087158,
0.036258239299058914,
0.021142181009054184,
-0.07180505990982056,
0.050522468984127045,
-... |
60e196af-fcc7-4000-9ca1-cb715dbf225a | Returned value
Returns binary string ciphertext.
String
Examples
Example encryption
``sql title=Query
CREATE TABLE encryption_test
(
comment
String,
secret` String
)
ENGINE = MergeTree;
INSERT INTO encryption_test VALUES
('aes-256-ofb no IV', encrypt('aes-256-ofb', 'Secret', '12345678910121314151617181920212... | {"source_file": "encryption-functions.md"} | [
0.03678427264094353,
0.030270781368017197,
-0.04729733243584633,
0.030054179951548576,
-0.06820983439683914,
-0.05660593882203102,
0.07739853858947754,
0.016987750306725502,
-0.009548848494887352,
-0.030468570068478584,
-0.007169697899371386,
-0.10480202734470367,
0.11114479601383209,
-0.0... |
802706a7-2d66-4034-b26d-3f5581ba2179 | Returned value
Returns the decrypted String, or
NULL
if decryption fails.
Nullable(String)
Examples
Create table and insert data
```sql title=Query
-- Let's create a table where user_id is the unique user id, encrypted is an encrypted string field, iv is an initial vector for decrypt/encrypt.
-- Assume that ... | {"source_file": "encryption-functions.md"} | [
0.014014736749231815,
0.03169182687997818,
-0.033721309155225754,
0.01815032586455345,
-0.0639154314994812,
-0.06311149895191193,
0.061852775514125824,
0.0720270499587059,
0.005413273815065622,
-0.047339070588350296,
0.01415436714887619,
-0.0712522566318512,
0.001181925181299448,
-0.050145... |
2f7fdb4a-3176-4543-a33c-42c7aed9d282 | description: 'Documentation for Arithmetic Functions'
sidebar_label: 'Arithmetic'
slug: /sql-reference/functions/arithmetic-functions
title: 'Arithmetic Functions'
doc_type: 'reference'
Arithmetic functions
Overview {#overview}
Arithmetic functions work for any two operands of type
UInt8
,
UInt16
,
UInt32
, ... | {"source_file": "arithmetic-functions.md"} | [
0.016942618414759636,
0.0215641837567091,
0.006772194989025593,
-0.01187305897474289,
-0.06796830892562866,
-0.055830102413892746,
0.009530752897262573,
0.030730515718460083,
-0.018863992765545845,
-0.022467486560344696,
-0.025014454498887062,
-0.03712775558233261,
0.0029523447155952454,
-... |
6c31afd8-4dd2-4a60-b934-650ee6589ee8 | x1, x2]
β Accepts two values for averaging.
Returned value
Returns the average value of the provided arguments, promoted to the largest compatible type.
Examples
Numeric types
sql title=Query
SELECT avg2(toUInt8(3), 1.0) AS result, toTypeName(result) AS type;
-- The type returned is a Float64 as the UInt8... | {"source_file": "arithmetic-functions.md"} | [
0.02028554677963257,
-0.04350712150335312,
0.01854354329407215,
0.0985139012336731,
-0.07087481021881104,
-0.0467018261551857,
0.05325734242796898,
0.06591904908418655,
-0.045599374920129776,
-0.026967337355017662,
-0.04749686270952225,
-0.12594075500965118,
-0.0028287440072745085,
-0.0235... |
c345dedb-ef7b-4393-ac41-659ca84e2fbd | :::note
Division by `0` returns `inf`, `-inf`, or `nan`.
:::
Syntax
sql
divide(x, y)
Arguments
x
β Dividend -
y
β Divisor
Returned value
The quotient of x and y
Examples
Dividing two numbers
sql title=Query
SELECT divide(25,5) AS quotient, toTypeName(quotient)
response title=Response
5 Floa... | {"source_file": "arithmetic-functions.md"} | [
-0.0018684649839997292,
0.014384040609002113,
-0.05215068161487579,
-0.014347768388688564,
0.0007561289821751416,
-0.08608408272266388,
0.025823676958680153,
0.04742822423577309,
-0.03263231739401817,
0.03138406574726105,
0.04968663677573204,
-0.0783466100692749,
-0.021906910464167595,
0.0... |
e8c002f5-ecdf-4451-9120-39738fa3dd45 | Syntax
sql
gcd(x, y)
Arguments
x
β First integer -
y
β Second integer
Returned value
The greatest common divisor of
x
and
y
.
Examples
Usage example
sql title=Query
SELECT gcd(12, 18)
response title=Response
6
ifNotFinite {#ifNotFinite}
Introduced in: v20.3
Checks whether a floating p... | {"source_file": "arithmetic-functions.md"} | [
-0.00471923965960741,
0.01131201907992363,
-0.08018656820058823,
-0.026844194158911705,
0.05654219910502434,
-0.09934525936841965,
0.0684371367096901,
0.0536993071436882,
-0.012944203801453114,
0.01516631804406643,
0.02988376095890999,
-0.014958889223635197,
0.025394419208168983,
-0.005421... |
c3cbbd96-08c4-44c0-b453-b11b533d59ad | Syntax
sql
intDivOrZero(a, b)
Arguments
a
β Left hand operand.
(U)Int*
b
β Right hand operand.
(U)Int*
Returned value
Result of integer division of a and b, or zero.
Examples
Integer division by zero
sql title=Query
SELECT intDivOrZero(1, 0)
response title=Response
0
Dividing a minimal neg... | {"source_file": "arithmetic-functions.md"} | [
0.008092856034636497,
-0.009447852149605751,
-0.06163206696510315,
0.021897127851843834,
-0.004290115088224411,
-0.09525517374277115,
0.06285468488931656,
0.017528509721159935,
-0.02637193165719509,
0.0381942018866539,
0.005467725917696953,
-0.0777713879942894,
0.040969446301460266,
-0.012... |
887a89ec-15d2-44d9-92ad-01d87a6065f2 | Syntax
sql
midpoint(x1[, x2, ...])
Arguments
x1[, x2, ...]
β Accepts a single value or multiple values for averaging.
Returned value
Returns the average value of the provided arguments, promoted to the largest compatible type.
Examples
Numeric types
sql title=Query
SELECT midpoint(1, toUInt8(3), 0... | {"source_file": "arithmetic-functions.md"} | [
0.04420715570449829,
-0.010811557061970234,
0.055823806673288345,
0.008614422753453255,
-0.04783331975340843,
-0.04950971156358719,
0.02996988594532013,
0.12142167240381241,
-0.03552113100886345,
-0.011088411323726177,
-0.06625999510288239,
-0.1240687370300293,
0.0408238023519516,
0.012269... |
dbdbc63c-5123-4a42-bb39-1e30cbf2f2ea | The remainder is computed like in C++. Truncated division is used for
negative numbers.
An exception is thrown when dividing by zero or when dividing a minimal
negative number by minus one.
Syntax
sql
modulo(a, b)
Aliases
:
mod
Arguments
a
β The dividend -
b
β The divisor (modulus)
Returned value... | {"source_file": "arithmetic-functions.md"} | [
-0.007057083770632744,
0.00793254841119051,
-0.03706342354416847,
0.002277146792039275,
-0.016667546704411507,
-0.10211402177810669,
0.05690259858965874,
0.09003935009241104,
-0.02323441207408905,
-0.006050189025700092,
0.06119773909449577,
-0.009981576353311539,
0.06023029610514641,
-0.02... |
c6df6028-0458-45ed-8d6e-000d29970f75 | response title=Response
25.2
Difference with regular multiplication
sql title=Query
SELECT multiplyDecimal(toDecimal256(-12, 0), toDecimal32(-2.1, 1), 1)
response title=Response
ββmultiply(toDecimal64(-12.647, 3), toDecimal32(2.1239, 4))ββ
β -26.8609633 β
ββββββββββββ... | {"source_file": "arithmetic-functions.md"} | [
-0.023806091398000717,
-0.007855504751205444,
0.006997611373662949,
-0.04579285904765129,
-0.06927947700023651,
-0.09112538397312164,
0.012248825281858444,
0.014618433080613613,
0.0538194477558136,
0.01044409442692995,
0.03498050197958946,
-0.10338514298200607,
-0.0015889833448454738,
-0.0... |
d74e09fb-4d52-4743-ae85-0785842a59ff | Returned value
Returns the difference between
x
and the nearest integer not greater than
x
divisible by
y
.
Examples
Usage example
sql title=Query
SELECT positiveModulo(-1, 10)
response title=Response
9
positiveModuloOrNull {#positiveModuloOrNull}
Introduced in: v25.5
Calculates the remainder when ... | {"source_file": "arithmetic-functions.md"} | [
-0.009725306183099747,
0.057258348912000656,
-0.07956019043922424,
-0.012211126275360584,
0.005106484051793814,
-0.07239317148923874,
0.04605786129832268,
0.04506196454167366,
-0.03963252156972885,
-0.012263402342796326,
0.08029282093048096,
-0.05324758589267731,
0.08473976701498032,
0.002... |
49ca3b37-414a-4f61-97cc-648f1328d4e8 | description: 'Documentation for Type Conversion Functions'
sidebar_label: 'Type conversion'
slug: /sql-reference/functions/type-conversion-functions
title: 'Type Conversion Functions'
doc_type: 'reference'
Type conversion functions
Common issues with data conversion {#common-issues-with-data-conversion}
ClickHo... | {"source_file": "type-conversion-functions.md"} | [
0.04497753083705902,
-0.006253688130527735,
-0.027816446498036385,
0.06911084055900574,
-0.08946242928504944,
-0.0043761092238128185,
0.0826980397105217,
0.017930282279849052,
-0.1367632895708084,
-0.03195952624082565,
0.01437892485409975,
-0.08943168818950653,
0.026635320857167244,
-0.080... |
bfd33c3c-70ae-4492-b28c-155cdb7f1cc6 | When converting dates with times to numbers or vice versa, the date with time corresponds to the number of seconds since the beginning of the Unix epoch.
The
toString
function of the
DateTime
argument can take a second String argument containing the name of the time zone, for example:
Europe/Amsterdam
. In this ... | {"source_file": "type-conversion-functions.md"} | [
0.00045755563769489527,
0.0476207435131073,
-0.01703335903584957,
-0.0177101269364357,
0.01914013922214508,
-0.04019445925951004,
-0.05510954558849335,
0.08655595034360886,
0.02136569283902645,
-0.015579218044877052,
-0.04344185069203377,
-0.09285084158182144,
-0.022663123905658722,
-0.000... |
bf71629a-2cd7-421d-ad80-25763c11dd7c | Example
Query:
sql
SELECT
toBool(toUInt8(1)),
toBool(toInt8(-1)),
toBool(toFloat32(1.01)),
toBool('true'),
toBool('false'),
toBool('FALSE')
FORMAT Vertical
Result:
response
toBool(toUInt8(1)): true
toBool(toInt8(-1)): true
toBool(toFloat32(1.01)): true
toBool('true'): ... | {"source_file": "type-conversion-functions.md"} | [
-0.01564730331301689,
-0.026482075452804565,
-0.05949321389198303,
0.07595085352659225,
-0.05717385187745094,
0.029766149818897247,
0.09620429575443268,
0.07659199088811874,
-0.03159540891647339,
-0.02449210360646248,
-0.06152556464076042,
-0.06885484606027603,
0.06994912773370743,
-0.0065... |
3c658b50-8de0-4a12-aba7-046b1a6d506a | Syntax
sql
toInt8OrNull(x)
Arguments
x
β A String representation of a number.
String
.
Supported arguments:
- String representations of (U)Int8/16/32/128/256.
Unsupported arguments (return
\N
)
- String representations of Float32/64 values, including
NaN
and
Inf
.
- String representations of binary ... | {"source_file": "type-conversion-functions.md"} | [
0.0285625159740448,
0.03230224922299385,
-0.0438997820019722,
0.018187621608376503,
-0.07505126297473907,
0.00010187344742007554,
0.057640593498945236,
0.07535108923912048,
-0.08754542469978333,
-0.010993266478180885,
-0.00940866582095623,
-0.09069278091192245,
0.07005233317613602,
-0.0088... |
949c6d86-aa58-4bee-a841-0c3a36cc7dcd | Syntax
sql
toInt16(expr)
Arguments
expr
β Expression returning a number or a string representation of a number.
Expression
.
Supported arguments:
- Values or string representations of type (U)Int8/16/32/64/128/256.
- Values of type Float32/64.
Unsupported arguments:
- String representations of Float32/6... | {"source_file": "type-conversion-functions.md"} | [
0.046614937484264374,
0.027503130957484245,
-0.05826215818524361,
-0.016479339450597763,
-0.028096502646803856,
-0.06969369202852249,
0.05517103895545006,
0.0633556917309761,
-0.08582834154367447,
-0.014168414287269115,
-0.0038642992731183767,
-0.082957923412323,
0.04198194667696953,
0.037... |
fb15e576-21c4-44cc-8705-2d18692c8582 | :::note
If the input value cannot be represented within the bounds of
Int16
, overflow or underflow of the result occurs.
This is not considered an error.
:::
Returned value
16-bit integer value if successful, otherwise
NULL
.
Int16
/
NULL
.
:::note
The function uses
rounding towards zero
, meaning it t... | {"source_file": "type-conversion-functions.md"} | [
0.03897770121693611,
0.06621483713388443,
-0.052571654319763184,
-0.003557324642315507,
-0.07293956726789474,
-0.014611279591917992,
0.04977947473526001,
0.07331597059965134,
-0.07292044907808304,
-0.0018449350027367473,
0.02148464135825634,
-0.06091995909810066,
0.05504060164093971,
0.006... |
c478c6fc-2128-4dce-a73b-768e4f4010a2 | Unsupported arguments:
- String representations of Float32/64 values, including
NaN
and
Inf
.
- String representations of binary and hexadecimal values, e.g.
SELECT toInt32('0xc0fe');
.
:::note
If the input value cannot be represented within the bounds of
Int32
, the result over or under flows.
This is not consi... | {"source_file": "type-conversion-functions.md"} | [
0.0007340150186792016,
-0.014095989987254143,
-0.1053013727068901,
-0.0037413707468658686,
-0.04732148349285126,
-0.053976964205503464,
0.049947477877140045,
0.05012315884232521,
-0.043786752969026566,
0.006571974139660597,
-0.03948104381561279,
-0.10849489271640778,
0.008981465362012386,
... |
948414a9-be47-4d04-99f5-57916f3b9f10 | Example
Query:
sql
SELECT
toInt32OrNull('-32'),
toInt32OrNull('abc')
FORMAT Vertical;
Result:
response
Row 1:
ββββββ
toInt32OrNull('-32'): -32
toInt32OrNull('abc'): α΄Ία΅α΄Έα΄Έ
See also
toInt32
.
toInt32OrZero
.
toInt32OrDefault
.
toInt32OrDefault {#toint32ordefault}
Like
toInt32
, this functi... | {"source_file": "type-conversion-functions.md"} | [
0.040355414152145386,
-0.009334113448858261,
-0.05855618417263031,
0.05837629735469818,
-0.07015995681285858,
-0.004908485803753138,
0.06289724260568619,
0.08049783110618591,
-0.03745449706912041,
0.0025926704984158278,
-0.030533812940120697,
-0.09447772800922394,
0.04397681728005409,
0.00... |
39d19c98-39e0-44cf-b624-315c2673291a | :::
Returned value
64-bit integer value.
Int64
.
:::note
The function uses
rounding towards zero
, meaning it truncates fractional digits of numbers.
:::
Example
Query:
sql
SELECT
toInt64(-64),
toInt64(-64.64),
toInt64('-64')
FORMAT Vertical;
Result:
response
Row 1:
ββββββ
toInt64(-64)... | {"source_file": "type-conversion-functions.md"} | [
0.06505885720252991,
0.041396427899599075,
-0.07832472026348114,
0.04575009271502495,
-0.05093134939670563,
-0.019949719309806824,
0.036864351481199265,
0.04585231840610504,
-0.05294003710150719,
0.0025831768289208412,
-0.031730785965919495,
-0.04220321774482727,
0.012308124452829361,
-0.0... |
071a5195-1fdf-4586-a459-b9838a3b1f77 | Result:
response
Row 1:
ββββββ
toInt64OrNull('-64'): -64
toInt64OrNull('abc'): α΄Ία΅α΄Έα΄Έ
See also
toInt64
.
toInt64OrZero
.
toInt64OrDefault
.
toInt64OrDefault {#toint64ordefault}
Like
toInt64
, this function converts an input value to a value of type
Int64
but returns the default value in case of an er... | {"source_file": "type-conversion-functions.md"} | [
0.052871935069561005,
0.030789609998464584,
-0.0928928330540657,
0.03505496680736542,
-0.06514143943786621,
0.008783403784036636,
0.04528774321079254,
0.05352010950446129,
-0.07159075140953064,
0.017666976898908615,
0.012872295454144478,
-0.0771256759762764,
0.03219906985759735,
0.00157530... |
1a173804-bb54-4ee7-bd71-b541dd09e221 | Result:
response
Row 1:
ββββββ
toInt128(-128): -128
toInt128(-128.8): -128
toInt128('-128'): -128
See also
toInt128OrZero
.
toInt128OrNull
.
toInt128OrDefault
.
toInt128OrZero {#toint128orzero}
Like
toInt128
, this function converts an input value to a value of type
Int128
but returns
0
in case... | {"source_file": "type-conversion-functions.md"} | [
0.016352172940969467,
0.051780954003334045,
-0.08285735547542572,
0.03729378432035446,
-0.046238385140895844,
-0.009746565483510494,
0.07008258998394012,
0.07644157856702805,
-0.0962265357375145,
-0.014751981012523174,
-0.040824033319950104,
-0.0739031657576561,
0.04313013702630997,
-0.024... |
0bf2e38a-de36-49b0-a704-b9409226e5af | Syntax
sql
toInt128OrDefault(expr[, default])
Arguments
expr
β Expression returning a number or a string representation of a number.
Expression
/
String
.
default
(optional) β The default value to return if parsing to type
Int128
is unsuccessful.
Int128
.
Supported arguments:
- (U)Int8/16/32/64/12... | {"source_file": "type-conversion-functions.md"} | [
0.03523910790681839,
0.00956770684570074,
-0.07221923023462296,
-0.018509946763515472,
-0.044528085738420486,
-0.042357437312603,
0.07843869179487228,
0.09093637019395828,
-0.08471307158470154,
-0.02387179248034954,
-0.02825530432164669,
-0.0542563758790493,
-0.009079999290406704,
0.034738... |
29ba66ce-51a6-4ac0-aefe-4a880135f9a0 | Syntax
sql
toInt256OrZero(x)
Arguments
x
β A String representation of a number.
String
.
Supported arguments:
- String representations of (U)Int8/16/32/128/256.
Unsupported arguments (return
0
):
- String representations of Float32/64 values, including
NaN
and
Inf
.
- String representations of binar... | {"source_file": "type-conversion-functions.md"} | [
0.027844293043017387,
0.0024955642875283957,
-0.0886588767170906,
0.0012895484687760472,
-0.04050426930189133,
-0.04436272010207176,
0.08371832966804504,
0.025289159268140793,
-0.07777788490056992,
0.00837738811969757,
-0.019730709493160248,
-0.085232213139534,
0.05089106783270836,
-0.0290... |
fe2f82c7-7bd0-4203-b876-1c23b8786e6e | Arguments for which the default value is returned:
- String representations of Float32/64 values, including
NaN
and
Inf
- String representations of binary and hexadecimal values, e.g.
SELECT toInt256OrDefault('0xc0fe', CAST('-1', 'Int256'));
:::note
If the input value cannot be represented within the bounds of
... | {"source_file": "type-conversion-functions.md"} | [
0.04442860558629036,
-0.016680607572197914,
-0.09892929345369339,
-0.009501135908067226,
-0.07967661321163177,
-0.04503362998366356,
0.09101378917694092,
0.052930958569049835,
-0.08067851513624191,
0.023179545998573303,
-0.013949023559689522,
-0.06813111901283264,
0.009120278060436249,
-0.... |
c48347c0-2206-43e1-8b3d-47386bdddfca | :::note
If the input value cannot be represented within the bounds of
UInt8
, overflow or underflow of the result occurs.
This is not considered an error.
:::
Returned value
8-bit unsigned integer value if successful, otherwise
0
.
UInt8
.
:::note
The function uses
rounding towards zero
, meaning it trunc... | {"source_file": "type-conversion-functions.md"} | [
-0.01912241242825985,
0.03664986789226532,
-0.06061168015003204,
0.02316254936158657,
-0.10080637037754059,
-0.0025859579909592867,
0.07097847759723663,
0.06910055130720139,
-0.03342859819531441,
-0.017517544329166412,
-0.004434060771018267,
-0.0388963483273983,
0.0581212192773819,
-0.0147... |
4215efc7-1a78-4818-98d7-4c27d9f230f8 | Returned value
8-bit unsigned integer value if successful, otherwise returns the default value if passed or
0
if not.
UInt8
.
:::note
- The function uses
rounding towards zero
, meaning it truncates fractional digits of numbers.
- The default value type should be the same as the cast type.
:::
Example
Q... | {"source_file": "type-conversion-functions.md"} | [
0.015253057703375816,
0.032629068940877914,
-0.08383172005414963,
0.009728604927659035,
-0.13158273696899414,
-0.007909913547337055,
0.07492486387491226,
0.09245771914720535,
-0.02315385825932026,
-0.02004430815577507,
-0.0022208383306860924,
-0.05365375056862831,
-0.01315819751471281,
-0.... |
f01f4f79-eef8-437d-b999-bdef727b0fb0 | Example
Query:
sql
SELECT
toUInt16OrZero('16'),
toUInt16OrZero('abc')
FORMAT Vertical;
Result:
response
Row 1:
ββββββ
toUInt16OrZero('16'): 16
toUInt16OrZero('abc'): 0
See also
toUInt16
.
toUInt16OrNull
.
toUInt16OrDefault
.
toUInt16OrNull {#touint16ornull}
Like
toUInt16
, this functio... | {"source_file": "type-conversion-functions.md"} | [
0.053384002298116684,
0.01748235896229744,
-0.09798377007246017,
0.01685357093811035,
-0.10966838151216507,
-0.0033732561860233545,
0.058283913880586624,
0.04239233583211899,
-0.06911415606737137,
-0.010427599772810936,
0.014488954097032547,
-0.08981767296791077,
0.04340837150812149,
0.005... |
93a74413-a335-4b85-abbe-77ffe421a128 | Example
Query:
sql
SELECT
toUInt16OrDefault('16', CAST('0', 'UInt16')),
toUInt16OrDefault('abc', CAST('0', 'UInt16'))
FORMAT Vertical;
Result:
response
Row 1:
ββββββ
toUInt16OrDefault('16', CAST('0', 'UInt16')): 16
toUInt16OrDefault('abc', CAST('0', 'UInt16')): 0
See also
toUInt16
.
toUInt16OrZ... | {"source_file": "type-conversion-functions.md"} | [
0.019399870187044144,
-0.011828499846160412,
-0.10562089085578918,
0.017157401889562607,
-0.1086169108748436,
0.020581232383847237,
0.06891347467899323,
0.06724913418292999,
-0.02772006019949913,
-0.004467260558158159,
-0.03487896919250488,
-0.06088900938630104,
0.025428449735045433,
0.029... |
701fa006-b9bf-4961-afa1-f0008d1cce9a | Syntax
sql
toUInt32OrNull(x)
Arguments
x
β A String representation of a number.
String
.
Supported arguments:
- String representations of (U)Int8/16/32/128/256.
Unsupported arguments (return
\N
)
- String representations of Float32/64 values, including
NaN
and
Inf
.
- String representations of binar... | {"source_file": "type-conversion-functions.md"} | [
0.028608955442905426,
-0.012030167505145073,
-0.09887653589248657,
-0.007534450851380825,
-0.08358293771743774,
-0.0020761704072356224,
0.06060405448079109,
0.03526933118700981,
-0.03909246623516083,
0.004162466153502464,
-0.00866349320858717,
-0.09235050529241562,
0.04907074570655823,
-0.... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.