id stringlengths 36 36 | document stringlengths 3 3k | metadata stringlengths 23 69 | embeddings listlengths 384 384 |
|---|---|---|---|
489d2d09-e07c-4dc5-9080-bde25c586fe5 | description: 'quantileExact, quantileExactLow, quantileExactHigh, quantileExactExclusive,
quantileExactInclusive functions'
sidebar_position: 173
slug: /sql-reference/aggregate-functions/reference/quantileexact
title: 'quantileExact Functions'
doc_type: 'reference'
quantileExact functions
quantileExact {#quanti... | {"source_file": "quantileexact.md"} | [
-0.05503267049789429,
-0.0029429325368255377,
0.017305834218859673,
0.026664575561881065,
-0.10428397357463837,
-0.0718473345041275,
0.030811280012130737,
0.069960817694664,
0.020495908334851265,
-0.0028710556216537952,
0.004782371688634157,
-0.02583734504878521,
-0.011428505182266235,
-0.... |
cc5f66ca-90dd-4be6-8050-82f42eb93e1e | The return value depends on the quantile level and the number of elements in the selection, i.e. if the level is 0.5, then the function returns the lower median value for an even number of elements and the middle median value for an odd number of elements. Median is calculated similarly to the
median_low
implementati... | {"source_file": "quantileexact.md"} | [
-0.03339419886469841,
0.014280281029641628,
0.004128881264477968,
0.035615403205156326,
-0.03776434063911438,
-0.10632792860269547,
0.04832545295357704,
0.07872892171144485,
0.0007696716347709298,
-0.008594291284680367,
-0.00690985843539238,
-0.08032619953155518,
-0.00020091107580810785,
-... |
43f552e3-756a-4a80-99ae-07cfa8fd3697 | Syntax
sql
quantileExactHigh(level)(expr)
Alias:
medianExactHigh
.
Arguments
level
β Level of quantile. Optional parameter. Constant floating-point number from 0 to 1. We recommend using a
level
value in the range of
[0.01, 0.99]
. Default value: 0.5. At
level=0.5
the function calculates
median
.
ex... | {"source_file": "quantileexact.md"} | [
-0.054399728775024414,
0.03040408343076706,
0.0400729700922966,
0.02689550444483757,
-0.06355789303779602,
-0.07520697265863419,
0.03421292081475258,
0.08398126065731049,
0.05118674784898758,
-0.006310367025434971,
-0.009800411760807037,
-0.024794751778244972,
-0.04024361073970795,
-0.0090... |
cba52052-870c-4b2e-9a1b-fe31e88ec796 | This function is equivalent to
PERCENTILE.INC
Excel function, (
type R7
).
When using multiple
quantileExactInclusive
functions with different levels in a query, the internal states are not combined (that is, the query works less efficiently than it could). In this case, use the
quantilesExactInclusive
function... | {"source_file": "quantileexact.md"} | [
-0.05125981569290161,
0.03777161240577698,
0.010128902271389961,
-0.009091053158044815,
-0.04272015392780304,
-0.03438489884138107,
0.007840495556592941,
0.10058712959289551,
0.020824888721108437,
0.000902312807738781,
0.014399231411516666,
-0.12836164236068726,
0.00030979426810517907,
-0.... |
10dd367a-448e-4079-851e-ec7de8a89868 | description: 'Documentation for ALTER DATABASE ... MODIFY COMMENT statements
which allow adding, modifying, or removing database comments.'
slug: /sql-reference/statements/alter/database-comment
sidebar_position: 51
sidebar_label: 'ALTER DATABASE ... MODIFY COMMENT'
title: 'ALTER DATABASE ... MODIFY COMMENT Statements'... | {"source_file": "database-comment.md"} | [
-0.02357841655611992,
-0.07250310480594635,
0.008671767078340054,
0.10414379835128784,
-0.03318572789430618,
-0.012399244122207165,
0.06896423548460007,
-0.01224430464208126,
0.005628011655062437,
0.038763534277677536,
0.02211238630115986,
0.015676524490118027,
0.1302347332239151,
-0.04253... |
2c58e52f-ae52-4a40-8fcb-ae2714c739e6 | description: 'Documentation for Manipulations with Table TTL'
sidebar_label: 'TTL'
sidebar_position: 44
slug: /sql-reference/statements/alter/ttl
title: 'Manipulations with Table TTL'
doc_type: 'reference'
Manipulations with Table TTL
:::note
If you are looking for details on using TTL for managing old data, chec... | {"source_file": "ttl.md"} | [
-0.015923835337162018,
0.006250524893403053,
0.03029228188097477,
0.04756340757012367,
-0.08819004893302917,
0.002006958005949855,
0.01632610522210598,
-0.010794081725180149,
-0.002593612065538764,
0.01649855449795723,
0.042495131492614746,
0.008548783138394356,
0.02526424452662468,
-0.057... |
1f6500be-ddd2-41ad-8338-62b768ec6856 | description: 'Documentation for ALTER TABLE ... MODIFY QUERY Statement'
sidebar_label: 'VIEW'
sidebar_position: 50
slug: /sql-reference/statements/alter/view
title: 'ALTER TABLE ... MODIFY QUERY Statement'
doc_type: 'reference'
ALTER TABLE ... MODIFY QUERY Statement
You can modify
SELECT
query that was specifie... | {"source_file": "view.md"} | [
-0.020260728895664215,
-0.017588991671800613,
0.011414910666644573,
0.06133453547954559,
-0.0742189958691597,
-0.00827381107956171,
0.020766915753483772,
0.011736461892724037,
-0.007476535625755787,
0.08764566481113434,
0.014790081419050694,
-0.027000319212675095,
0.01760832965373993,
-0.0... |
2e1e94e0-c6c4-428a-ba68-d46e6da1ed27 | SELECT ts, event_type, browser, sum(events_cnt) events_cnt, round(sum(cost),2) cost
FROM events_by_day
GROUP BY ts, event_type, browser
ORDER BY ts, event_type;
βββββββββββββββββββtsββ¬βevent_typeββ¬βbrowserββ¬βevents_cntββ¬βcostββ
β 2020-01-01 00:00:00 β click β β 48 β 0 β
β 2020-01-01 00:00:00 β... | {"source_file": "view.md"} | [
0.01734156720340252,
-0.004697415977716446,
0.054204776883125305,
0.09272976964712143,
-0.051080070436000824,
-0.016043834388256073,
0.10439549386501312,
-0.030369708314538002,
0.027077889069914818,
0.008026443421840668,
-0.012058544903993607,
-0.12534943222999573,
-0.0032511798199266195,
... |
1d215a61-0660-4e5e-a852-c7b516f3f0ec | -- !!! The columns' definition is unchanged but it does not matter, we are not querying
-- MATERIALIZED VIEW, we are querying TO (storage) table.
-- SELECT section is updated.
SHOW CREATE TABLE mv FORMAT TSVRaw;
CREATE MATERIALIZED VIEW test.mv TO test.events_by_day
(
ts
DateTime,
event_type
String,
... | {"source_file": "view.md"} | [
-0.03793421760201454,
-0.07160649448633194,
-0.04480958357453346,
0.08522501587867737,
-0.0696796178817749,
-0.040817756205797195,
-0.030611446127295494,
0.016071349382400513,
0.03542241081595421,
0.09989115595817566,
0.05535176023840904,
-0.05324177071452141,
0.02438206598162651,
-0.02607... |
737ed722-dc91-436b-80b2-740a85503f12 | description: 'Documentation for Column'
sidebar_label: 'COLUMN'
sidebar_position: 37
slug: /sql-reference/statements/alter/column
title: 'Column Manipulations'
doc_type: 'reference'
A set of queries that allow changing the table structure.
Syntax:
sql
ALTER [TEMPORARY] TABLE [db].name [ON CLUSTER cluster] ADD|D... | {"source_file": "column.md"} | [
-0.021916547790169716,
-0.009167891927063465,
-0.061971791088581085,
0.1279682219028473,
0.01276978850364685,
0.04441466182470322,
-0.010120067745447159,
-0.023173213005065918,
-0.037255026400089264,
0.09662152081727982,
0.04381208494305611,
0.0007031714194454253,
0.03796372935175896,
-0.1... |
c90a65ea-7e4c-4f1f-a465-5568abaaf563 | DROP COLUMN {#drop-column}
sql
DROP COLUMN [IF EXISTS] name
Deletes the column with the name
name
. If the
IF EXISTS
clause is specified, the query won't return an error if the column does not exist.
Deletes data from the file system. Since this deletes entire files, the query is completed almost instantly.
... | {"source_file": "column.md"} | [
-0.042154937982559204,
-0.06013250723481178,
-0.03236245736479759,
0.04452936723828316,
0.004195772111415863,
-0.11483369767665863,
0.052789438515901566,
-0.06544850021600723,
0.09061173349618912,
0.06308577954769135,
0.10457426309585571,
0.017744014039635658,
0.021418167278170586,
-0.0856... |
a6a709be-276a-4e65-9cfe-9c4ca9700833 | For examples of column-level settings modifying, see
Column-level Settings
.
If the
IF EXISTS
clause is specified, the query won't return an error if the column does not exist.
When changing the type, values are converted as if the
toType
functions were applied to them. If only the default expression is change... | {"source_file": "column.md"} | [
0.009697233326733112,
-0.05688748508691788,
0.01123209111392498,
0.054154347628355026,
-0.027573253959417343,
-0.04475622996687889,
-0.03771105781197548,
0.04226274415850639,
0.0014013779582455754,
0.042111244052648544,
0.06856491416692734,
-0.009993011131882668,
-0.045976344496011734,
-0.... |
d4a5b9ae-7630-45be-9bc6-fdd2b6ae6fbe | Syntax:
sql
ALTER TABLE table_name MODIFY COLUMN column_name RESET SETTING name,...;
Example
Reset column setting
max_compress_block_size
to it's default value:
sql
ALTER TABLE table_name MODIFY COLUMN column_name RESET SETTING max_compress_block_size;
MATERIALIZE COLUMN {#materialize-column}
Materializes... | {"source_file": "column.md"} | [
-0.04597313702106476,
-0.005431346129626036,
-0.032233826816082,
0.0708717554807663,
-0.05781864374876022,
-0.037380728870630264,
-0.01465153880417347,
-0.02683963067829609,
-0.04763518273830414,
0.13474620878696442,
0.01857764646410942,
0.019046103581786156,
-0.016632655635476112,
-0.0515... |
10becc58-b588-44a5-9b05-26346374bf8c | ALTER TABLE tmp MATERIALIZE COLUMN s;
SELECT groupArray(x), groupArray(s) FROM tmp;
ββgroupArray(x)ββββββββββ¬βgroupArray(s)ββββββββββββββββββββββββββββββββββββββββββ
β [0,1,2,3,4,5,6,7,8,9] β ['inf','100','50','33','25','20','17','14','12','11'] β
βββββββββββββββββββββββββ΄βββββββββββββββββββββββββββββββββββββββββββ... | {"source_file": "column.md"} | [
-0.022680146619677544,
0.03746715560555458,
0.01621364988386631,
0.014440614730119705,
0.029541531577706337,
-0.06591591984033585,
-0.0010378507431596518,
-0.06777986139059067,
-0.05667376518249512,
0.08547496050596237,
0.0014020116068422794,
-0.0014928621239960194,
-0.0126110864803195,
-0... |
0de69596-2f88-4e52-b0c1-492a51cd8b75 | description: 'Documentation for Manipulating SAMPLE BY expression'
sidebar_label: 'SAMPLE BY'
sidebar_position: 41
slug: /sql-reference/statements/alter/sample-by
title: 'Manipulating Sampling-Key Expressions'
doc_type: 'reference'
Manipulating SAMPLE BY expression
The following operations are available:
MODIFY... | {"source_file": "sample-by.md"} | [
-0.03245653584599495,
0.05019740015268326,
-0.011854139156639576,
0.050556689500808716,
0.05677475035190582,
-0.010701438412070274,
0.06188930943608284,
-0.0007831386756151915,
-0.020870670676231384,
0.08893747627735138,
0.04111072048544884,
-0.02384585328400135,
0.036684878170490265,
-0.1... |
59587c31-881b-4e40-9d7b-898f2923e973 | description: 'Documentation for Manipulating Key Expressions'
sidebar_label: 'ORDER BY'
sidebar_position: 41
slug: /sql-reference/statements/alter/order-by
title: 'Manipulating Key Expressions'
doc_type: 'reference'
Manipulating Key Expressions
sql
ALTER TABLE [db].name [ON CLUSTER cluster] MODIFY ORDER BY new_ex... | {"source_file": "order-by.md"} | [
-0.002772899577394128,
0.015487092547118664,
0.02545354887843132,
0.03768086060881615,
-0.02443445846438408,
0.04156510904431343,
-0.02391333319246769,
-0.0006355260848067701,
-0.0010177554795518517,
0.15308186411857605,
0.06420944631099701,
0.03163841739296913,
0.00798793788999319,
-0.088... |
ae1d0d2f-1de2-49d1-9d8f-2d62f1fecddb | description: 'Documentation for Manipulating Column Statistics'
sidebar_label: 'STATISTICS'
sidebar_position: 45
slug: /sql-reference/statements/alter/statistics
title: 'Manipulating Column Statistics'
doc_type: 'reference'
import ExperimentalBadge from '@theme/badges/ExperimentalBadge';
import CloudNotSupportedBad... | {"source_file": "statistics.md"} | [
-0.011139828711748123,
0.017446689307689667,
-0.05748383700847626,
0.08117444813251495,
-0.008470515720546246,
0.008208313025534153,
0.021969608962535858,
-0.026987595483660698,
-0.022385310381650925,
0.12471001595258713,
0.02604934759438038,
-0.039680950343608856,
0.06989865005016327,
-0.... |
2a353d48-8ea3-42ce-801a-5dc3e4185ae5 | description: 'Documentation for Manipulating Projections'
sidebar_label: 'PROJECTION'
sidebar_position: 49
slug: /sql-reference/statements/alter/projection
title: 'Projections'
doc_type: 'reference'
Projections store data in a format that optimizes query execution, this feature is useful for:
- Running queries on a... | {"source_file": "projection.md"} | [
-0.041210055351257324,
0.025941502302885056,
-0.09292278438806534,
0.07492255419492722,
-0.005533158779144287,
-0.037654224783182144,
0.06445257365703583,
-0.0019226876320317388,
-0.013989155180752277,
0.05246969684958458,
0.016428235918283463,
0.01858663186430931,
0.11591644585132599,
-0.... |
8165c46f-3ae6-4e78-b3a7-39b8656ec250 | sql
INSERT INTO visits SELECT
number,
'test',
1. * (number / 2),
'IOS'
FROM numbers(100, 500);
We will execute a first query using
GROUP BY
using the field
user_agent
, this query will not use the projection defined as the pre-aggregation does not match.
sql
SELECT
user_agent,
count(DISTINCT... | {"source_file": "projection.md"} | [
0.06000871583819389,
0.028184572234749794,
-0.011674284934997559,
0.054397959262132645,
-0.11130265891551971,
0.0000856970000313595,
0.11190740764141083,
-0.012505407445132732,
0.023453891277313232,
0.0344921350479126,
0.016402026638388634,
-0.04569067060947418,
0.09413847327232361,
-0.001... |
dd3ddd50-21e5-4564-925f-88c753a0cf04 | The commands
ADD
,
DROP
and
CLEAR
are lightweight in a sense that they only change metadata or remove files.
Also, they are replicated, syncing projections metadata via ClickHouse Keeper or ZooKeeper.
:::note
Projection manipulation is supported only for tables with
*MergeTree
engine (including
replicated
... | {"source_file": "projection.md"} | [
-0.054472822695970535,
-0.029910340905189514,
-0.044063009321689606,
0.008417661301791668,
0.06909142434597015,
-0.054170161485672,
-0.0005573269445449114,
-0.018034595996141434,
0.029040036723017693,
0.0913342833518982,
0.05259505286812782,
-0.005730386823415756,
-0.015577221289277077,
-0... |
7209e864-3008-4f1a-8802-2f9f8ac8dcd6 | description: 'Documentation for Apply mask of deleted rows'
sidebar_label: 'APPLY DELETED MASK'
sidebar_position: 46
slug: /sql-reference/statements/alter/apply-deleted-mask
title: 'Apply mask of deleted rows'
doc_type: 'reference'
Apply mask of deleted rows
sql
ALTER TABLE [db].name [ON CLUSTER cluster] APPLY DE... | {"source_file": "apply-deleted-mask.md"} | [
-0.01889670640230179,
0.0075762164779007435,
0.005982131697237492,
0.02687842771410942,
0.03364001587033272,
-0.04893554374575615,
0.04533834755420685,
-0.10375968366861343,
0.017443375661969185,
0.013573606498539448,
0.06493418663740158,
-0.0272507406771183,
0.07114890962839127,
-0.070913... |
47a17d9f-0c8c-4aa4-8742-e8a4efdc6ae9 | description: 'Documentation for ALTER NAMED COLLECTION'
sidebar_label: 'NAMED COLLECTION'
slug: /sql-reference/statements/alter/named-collection
title: 'ALTER NAMED COLLECTION'
doc_type: 'reference'
import CloudNotSupportedBadge from '@theme/badges/CloudNotSupportedBadge';
ALTER NAMED COLLECTION
This query in... | {"source_file": "named-collection.md"} | [
-0.028754061087965965,
0.010536769405007362,
0.02742360532283783,
0.042641062289476395,
-0.07665020227432251,
0.010619877837598324,
0.027685124427080154,
-0.08052613586187363,
0.03331577032804489,
0.07911061495542526,
0.042153242975473404,
-0.05864740535616875,
0.0699273943901062,
-0.10066... |
99ecddc7-9049-4eb3-9815-aac9b7ad2e3b | description: 'Documentation for ALTER TABLE ... MODIFY COMMENT which allow
adding, modifying, or removing table comments'
sidebar_label: 'ALTER TABLE ... MODIFY COMMENT'
sidebar_position: 51
slug: /sql-reference/statements/alter/comment
title: 'ALTER TABLE ... MODIFY COMMENT'
keywords: ['ALTER TABLE', 'MODIFY COMMENT']... | {"source_file": "comment.md"} | [
-0.028975753113627434,
-0.07570283114910126,
0.022584905847907066,
0.10257647931575775,
-0.01463942788541317,
0.001550663961097598,
0.05752138793468475,
0.002397045260295272,
-0.0008850035956129432,
0.0856083482503891,
0.03457207605242729,
-0.0031454323325306177,
0.12118124216794968,
-0.06... |
317205d8-fd37-4cf8-b807-523f24bdd2dc | description: 'Documentation for Partition'
sidebar_label: 'PARTITION'
sidebar_position: 38
slug: /sql-reference/statements/alter/partition
title: 'Manipulating Partitions and Parts'
doc_type: 'reference'
The following operations with
partitions
are available:
DETACH PARTITION\|PART
β Moves a partition or par... | {"source_file": "partition.md"} | [
-0.026192471385002136,
-0.020793259143829346,
0.03147709742188454,
0.03234903886914253,
0.044782087206840515,
-0.03391389921307564,
0.05112587288022041,
0.032562341541051865,
-0.023496301844716072,
-0.01552728470414877,
0.03338112682104111,
0.016207613050937653,
0.054670628160238266,
-0.01... |
356726d7-a817-49cf-8c77-7327f2bf451c | DROP PARTITION\|PART {#drop-partitionpart}
sql
ALTER TABLE table_name [ON CLUSTER cluster] DROP PARTITION|PART partition_expr
Deletes the specified partition from the table. This query tags the partition as inactive and deletes data completely, approximately in 10 minutes.
Read about setting the partition express... | {"source_file": "partition.md"} | [
-0.002187849720939994,
0.029850158840417862,
0.08528310060501099,
0.05146448314189911,
0.06661812216043472,
-0.06953749805688858,
0.07653072476387024,
-0.01325976848602295,
0.01350475661456585,
0.01979285106062889,
0.02932383492588997,
-0.053559936583042145,
0.046946462243795395,
0.0316808... |
3e4a4385-8481-4800-bb90-11e77966bdec | Both tables must have the same structure.
Both tables must have the same partition key, the same order by key and the same primary key.
Both tables must have the same storage policy.
The destination table must include all indices and projections from the source table. If the
enforce_index_structure_match_on_part... | {"source_file": "partition.md"} | [
-0.003296470968052745,
-0.029253121465444565,
0.02490329183638096,
0.049521949142217636,
0.015592892654240131,
-0.06706313043832779,
0.061499472707509995,
-0.049798715859651566,
-0.01698506809771061,
-0.016781413927674294,
0.01127584371715784,
-0.03316883742809296,
0.060274578630924225,
-0... |
af1638a9-c6ef-46f2-a836-4e8464fd16e1 | Example:
sql
ALTER TABLE visits CLEAR COLUMN hour in PARTITION 201902
FREEZE PARTITION {#freeze-partition}
sql
ALTER TABLE table_name [ON CLUSTER cluster] FREEZE [PARTITION partition_expr] [WITH NAME 'backup_name']
This query creates a local backup of a specified partition. If the
PARTITION
clause is omitted,... | {"source_file": "partition.md"} | [
-0.06216754764318466,
-0.019930660724639893,
0.038502324372529984,
0.06871991604566574,
0.0326005257666111,
-0.01619841530919075,
0.01205296628177166,
0.0024555183481425047,
0.019301660358905792,
-0.008678039535880089,
0.025224577635526657,
-0.0033686186652630568,
0.07714194059371948,
-0.1... |
45a20a5f-bf7d-48b1-b144-d3f8602a0406 | UNFREEZE PARTITION {#unfreeze-partition}
sql
ALTER TABLE table_name [ON CLUSTER cluster] UNFREEZE [PARTITION 'part_expr'] WITH NAME 'backup_name'
Removes
frozen
partitions with the specified name from the disk. If the
PARTITION
clause is omitted, the query removes the backup of all partitions at once.
CLEAR I... | {"source_file": "partition.md"} | [
-0.0018080982845276594,
0.013925699517130852,
0.028243884444236755,
0.09386506676673889,
0.041177455335855484,
-0.05422266200184822,
0.06698071211576462,
-0.014820353128015995,
0.023302629590034485,
0.022698158398270607,
0.03518303111195564,
-0.0015765666030347347,
0.06945206224918365,
-0.... |
d0c93ab1-82ae-42a0-81bf-13fb70402b32 | Returns an error if the specified disk or volume is not configured. Query also returns an error if conditions of data moving, that specified in the storage policy, can't be applied.
Can return an error in the case, when data to be moved is already moved by a background process, concurrent
ALTER TABLE t MOVE
query o... | {"source_file": "partition.md"} | [
-0.018573954701423645,
-0.02300497516989708,
0.04238450899720192,
0.01756402663886547,
0.02948453091084957,
-0.05903118848800659,
0.09479890763759613,
-0.005719443783164024,
0.020169999450445175,
0.02239341475069523,
0.07049141824245453,
-0.04274555668234825,
0.08803530037403107,
-0.065387... |
cf43832c-ec65-4538-bc33-e015f75c0c35 | Using the partition ID. Partition ID is a string identifier of the partition (human-readable, if possible) that is used as the names of partitions in the file system and in ZooKeeper. The partition ID must be specified in the
PARTITION ID
clause, in a single quotes. For example,
ALTER TABLE visits DETACH PARTITION I... | {"source_file": "partition.md"} | [
-0.005604997277259827,
0.03247553110122681,
0.0558602474629879,
0.03366644307971001,
0.0472007654607296,
-0.029366804286837578,
0.0959889218211174,
0.08195380121469498,
-0.010203183628618717,
0.01716129295527935,
-0.010996534489095211,
-0.0577952116727829,
0.012250260449945927,
0.022167719... |
66528a2a-fa74-4ac7-8245-d6b5ec0bdd27 | description: 'Documentation for ALTER'
sidebar_label: 'ALTER'
sidebar_position: 35
slug: /sql-reference/statements/alter/
title: 'ALTER'
doc_type: 'reference'
ALTER
Most
ALTER TABLE
queries modify table settings or data:
| Modifier |
|... | {"source_file": "index.md"} | [
-0.026393361389636993,
0.026622187346220016,
0.0906812772154808,
0.09210176765918732,
-0.02475891448557377,
0.04548206180334091,
0.03844565525650978,
0.025261929258704185,
0.02585553750395775,
0.03890718147158623,
0.029898596927523613,
-0.07418349385261536,
0.05868510529398918,
-0.07330288... |
e3cee4bc-4887-4b69-b5d2-d2a57adc1afa | For
*MergeTree
tables mutations execute by
rewriting whole data parts
.
There is no atomicity β parts are substituted for mutated parts as soon as they are ready and a
SELECT
query that started executing during a mutation will see data from parts that have already been mutated along with data from parts that have... | {"source_file": "index.md"} | [
0.004431433044373989,
-0.0408867672085762,
0.008419734425842762,
-0.010264500975608826,
0.018385306000709534,
-0.1169179305434227,
-0.021112963557243347,
0.0036483127623796463,
0.036064330488443375,
0.03180811554193497,
0.06052689626812935,
0.04600212350487709,
0.05483590066432953,
-0.0633... |
40b68a84-a448-4c7e-8de7-fb6dae51492e | description: 'Documentation for Settings Profile'
sidebar_label: 'SETTINGS PROFILE'
sidebar_position: 48
slug: /sql-reference/statements/alter/settings-profile
title: 'ALTER SETTINGS PROFILE'
doc_type: 'reference'
Changes settings profiles.
Syntax:
sql
ALTER SETTINGS PROFILE [IF EXISTS] name1 [RENAME TO new_nam... | {"source_file": "settings-profile.md"} | [
0.07052012532949448,
0.02909393236041069,
0.003004854079335928,
0.0926826223731041,
-0.05678972974419594,
0.06655719876289368,
0.052823785692453384,
0.0615607313811779,
-0.15423552691936493,
-0.005568712018430233,
0.013531113043427467,
-0.08202550560235977,
0.0986635833978653,
-0.040129080... |
f9c51a8c-18d1-4159-b246-cc1b204c327b | description: 'Documentation for Manipulating Constraints'
sidebar_label: 'CONSTRAINT'
sidebar_position: 43
slug: /sql-reference/statements/alter/constraint
title: 'Manipulating Constraints'
doc_type: 'reference'
Manipulating Constraints
Constraints could be added or deleted using following syntax:
sql
ALTER TAB... | {"source_file": "constraint.md"} | [
-0.012543891556560993,
0.009487086907029152,
-0.01581135392189026,
0.04561125487089157,
0.02664291113615036,
0.007935975678265095,
0.0042546591721475124,
-0.0778920128941536,
-0.05744097754359245,
0.0650373175740242,
0.05025685951113701,
-0.03440386429429054,
0.05568879842758179,
-0.022360... |
b063a074-0774-4218-8708-37d6d01719de | description: 'Documentation for ALTER TABLE ... DELETE Statement'
sidebar_label: 'DELETE'
sidebar_position: 39
slug: /sql-reference/statements/alter/delete
title: 'ALTER TABLE ... DELETE Statement'
doc_type: 'reference'
ALTER TABLE ... DELETE Statement
sql
ALTER TABLE [db.]table [ON CLUSTER cluster] DELETE WHERE ... | {"source_file": "delete.md"} | [
-0.02097899839282036,
0.02399297244846821,
0.041078150272369385,
0.08126524835824966,
0.030777577310800552,
-0.06093224883079529,
0.03725844994187355,
-0.0479762926697731,
0.06296779215335846,
0.018398161977529526,
0.07740073651075363,
-0.002748652594164014,
0.028073957189917564,
-0.091132... |
b97e78cd-d5ba-4713-8147-2d0f174177df | description: 'Documentation for ALTER TABLE ... UPDATE Statements'
sidebar_label: 'UPDATE'
sidebar_position: 40
slug: /sql-reference/statements/alter/update
title: 'ALTER TABLE ... UPDATE Statements'
doc_type: 'reference'
ALTER TABLE ... UPDATE Statements
sql
ALTER TABLE [db.]table [ON CLUSTER cluster] UPDATE col... | {"source_file": "update.md"} | [
-0.03429534286260605,
0.022164905443787575,
0.04293283820152283,
0.07374770194292068,
0.011128210462629795,
-0.046131256967782974,
0.04052789509296417,
-0.01822468638420105,
0.002383096143603325,
0.019903771579265594,
0.059055134654045105,
-0.035257160663604736,
0.015039614401757717,
-0.12... |
cc02ed56-73ce-4456-9337-274e25dd3612 | description: 'Documentation for User'
sidebar_label: 'USER'
sidebar_position: 45
slug: /sql-reference/statements/alter/user
title: 'ALTER USER'
doc_type: 'reference'
Changes ClickHouse user accounts.
Syntax:
sql
ALTER USER [IF EXISTS] name1 [RENAME TO new_name |, name2 [,...]]
[ON CLUSTER cluster_name]
... | {"source_file": "user.md"} | [
0.03340627998113632,
-0.01576109416782856,
-0.09740520268678665,
0.007957451976835728,
-0.051305633038282394,
0.018210066482424736,
0.03999742865562439,
-0.03227132186293602,
-0.06408558785915375,
0.0052642603404819965,
0.04609787464141846,
-0.06640277802944183,
0.09592332690954208,
-0.038... |
ca7b33ee-1175-4e29-b7d8-dec4a15e6f72 | sql
ALTER USER user DEFAULT ROLE ALL EXCEPT role1, role2
Allows the user with
john
account to grant his privileges to the user with
jack
account:
sql
ALTER USER john GRANTEES jack;
Adds new authentication methods to the user while keeping the existing ones:
sql
ALTER USER user1 ADD IDENTIFIED WITH plaintext... | {"source_file": "user.md"} | [
-0.028788117691874504,
-0.03688798099756241,
-0.009739726781845093,
-0.06555293500423431,
-0.10921372473239899,
0.0013595055788755417,
0.04111474007368088,
-0.044089801609516144,
-0.0510389506816864,
-0.0338275209069252,
0.07113257795572281,
0.03019898198544979,
0.05878017097711563,
-0.012... |
8d387dde-3eb6-48b8-bec1-82cba7499c2a | description: 'Documentation for Manipulating Data Skipping Indices'
sidebar_label: 'INDEX'
sidebar_position: 42
slug: /sql-reference/statements/alter/skipping-index
title: 'Manipulating Data Skipping Indices'
toc_hidden_folder: true
doc_type: 'reference'
Manipulating Data Skipping Indices
The following operations... | {"source_file": "skipping-index.md"} | [
0.005114880856126547,
0.014283237047493458,
0.02616311050951481,
0.1336318701505661,
0.06062373146414757,
-0.01189629640430212,
0.05857689306139946,
-0.06248736009001732,
-0.04683041572570801,
0.015589682385325432,
0.035738833248615265,
-0.033810924738645554,
0.05916028469800949,
-0.044302... |
d97d0d44-4cea-42f0-838e-7d78125da769 | description: 'Documentation for ALTER ROW POLICY'
sidebar_label: 'ROW POLICY'
sidebar_position: 47
slug: /sql-reference/statements/alter/row-policy
title: 'ALTER ROW POLICY'
doc_type: 'reference'
ALTER ROW POLICY
Changes row policy.
Syntax:
sql
ALTER [ROW] POLICY [IF EXISTS] name1 [ON CLUSTER cluster_name1] O... | {"source_file": "row-policy.md"} | [
0.005574579816311598,
0.05674505606293678,
-0.0008598439744673669,
0.04047084599733353,
0.0012826332822442055,
0.05141960829496384,
0.05787675082683563,
-0.06228672340512276,
-0.10321958363056183,
0.07179740816354752,
0.053427908569574356,
-0.015147458761930466,
0.06598217785358429,
-0.070... |
72dbbb88-f2ff-43e0-9e33-7f2006cbf63f | description: 'Documentation for Table Settings Manipulations'
sidebar_label: 'SETTING'
sidebar_position: 38
slug: /sql-reference/statements/alter/setting
title: 'Table Settings Manipulations'
doc_type: 'reference'
Table Settings Manipulations
There is a set of queries to change table settings. You can modify sett... | {"source_file": "setting.md"} | [
0.0380517803132534,
-0.012610046193003654,
0.058114442974328995,
0.07422641664743423,
-0.12803152203559875,
-0.008113575167953968,
0.002253604819998145,
0.04805530235171318,
-0.10316555947065353,
0.01925608329474926,
0.033374909311532974,
-0.034870695322752,
0.04835755378007889,
-0.1266789... |
80c9e0df-ba89-484d-b937-a9149cf008ce | description: 'Documentation for Role'
sidebar_label: 'ROLE'
sidebar_position: 46
slug: /sql-reference/statements/alter/role
title: 'ALTER ROLE'
doc_type: 'reference'
Changes roles.
Syntax:
sql
ALTER ROLE [IF EXISTS] name1 [RENAME TO new_name |, name2 [,...]]
[ON CLUSTER cluster_name]
[DROP ALL PROFILES... | {"source_file": "role.md"} | [
0.05601024627685547,
0.031531352549791336,
-0.002426165621727705,
0.09516396373510361,
-0.0385100319981575,
0.08043904602527618,
0.0630175992846489,
0.03501735255122185,
-0.14223168790340424,
0.0016950723947957158,
0.004393845330923796,
-0.05721747875213623,
0.08290490508079529,
-0.0479171... |
582b477a-2c9c-491a-8403-d75dd858b640 | description: 'Documentation for Quota'
sidebar_label: 'QUOTA'
sidebar_position: 46
slug: /sql-reference/statements/alter/quota
title: 'ALTER QUOTA'
doc_type: 'reference'
Changes quotas.
Syntax:
sql
ALTER QUOTA [IF EXISTS] name [ON CLUSTER cluster_name]
[RENAME TO new_name]
[KEYED BY {user_name | ip_addr... | {"source_file": "quota.md"} | [
-0.004047703463584185,
0.03586438298225403,
-0.02833154797554016,
0.06509678065776825,
-0.060859665274620056,
0.009107820689678192,
0.05814094841480255,
0.013327403925359249,
-0.01980341225862503,
0.04581919312477112,
-0.026005040854215622,
-0.07096738368272781,
0.09895673394203186,
-0.065... |
8ca328b6-d78e-4c73-a8f5-c64741c768a5 | description: 'Documentation for ARRAY JOIN Clause'
sidebar_label: 'ARRAY JOIN'
slug: /sql-reference/statements/select/array-join
title: 'ARRAY JOIN Clause'
doc_type: 'reference'
ARRAY JOIN Clause
It is a common operation for tables that contain an array column to produce a new table that has a row with each indiv... | {"source_file": "array-join.md"} | [
0.013163515366613865,
0.013289258815348148,
-0.0282882247120142,
0.08316485583782196,
-0.015948129817843437,
-0.03488082438707352,
0.06865577399730682,
0.025358034297823906,
-0.0474952757358551,
-0.05255180597305298,
-0.017245659604668617,
0.06394209712743759,
0.08154382556676865,
-0.06881... |
4764b68b-cfde-4ebb-ab64-a57072420317 | sql
SELECT
sum(length(GoalsReached)) AS Reaches,
count() AS Hits
FROM test.hits
WHERE (CounterID = 160656) AND notEmpty(GoalsReached)
text
ββReachesββ¬ββHitsββ
β 95606 β 31406 β
βββββββββββ΄ββββββββ
ARRAY JOIN and arrayEnumerateUniq {#array_join_arrayEnumerateUniq}
This function is useful when using
ARRA... | {"source_file": "array-join.md"} | [
0.07348181307315826,
0.06815588474273682,
-0.04366454854607582,
0.09176644682884216,
-0.03991852328181267,
0.06192963942885399,
0.08963284641504288,
0.009710322134196758,
0.042936522513628006,
-0.017101550474762917,
-0.08200498670339584,
-0.03454166650772095,
0.07904767245054245,
0.0034871... |
4be5e9e0-7706-4cc6-a378-abbc7dc88a5a | sql
SELECT s, arr, a, num, mapped
FROM arrays_test
ARRAY JOIN arr AS a, arrayEnumerate(arr) AS num, arrayMap(x -> x + 1, arr) AS mapped;
response
ββsββββββ¬βarrββββββ¬βaββ¬βnumββ¬βmappedββ
β Hello β [1,2] β 1 β 1 β 2 β
β Hello β [1,2] β 2 β 2 β 3 β
β World β [3,4,5] β 3 β 1 β 4 β
β World β [3,4,5... | {"source_file": "array-join.md"} | [
0.08304424583911896,
-0.04070762172341347,
-0.015741394832730293,
-0.025296751409769058,
-0.04226701334118843,
-0.03934168070554733,
0.06691884994506836,
-0.08782872557640076,
-0.06495657563209534,
0.06044463440775871,
-0.014897528104484081,
-0.005548468325287104,
0.07657790184020996,
-0.0... |
cf0a7b42-89ce-4511-bb2f-53798e48e9eb | This variation also makes sense:
sql
SELECT s, `nest.x`, `nest.y`
FROM nested_test
ARRAY JOIN `nest.x`;
response
ββsββββββ¬βnest.xββ¬βnest.yββββββ
β Hello β 1 β [10,20] β
β Hello β 2 β [10,20] β
β World β 3 β [30,40,50] β
β World β 4 β [30,40,50] β
β World β 5 β [30,40,50] β
βββββββββ΄ββ... | {"source_file": "array-join.md"} | [
0.0140458345413208,
0.016406506299972534,
0.022849097847938538,
0.05479166656732559,
0.027362501248717308,
-0.11373309046030045,
0.02561667375266552,
-0.027825340628623962,
-0.014193056151270866,
0.012594369240105152,
-0.016096843406558037,
0.01165818888694048,
0.01396770216524601,
-0.0077... |
7f01fa4d-e25e-49ea-98dd-8ad1770cd859 | description: 'Documentation for SAMPLE Clause'
sidebar_label: 'SAMPLE'
slug: /sql-reference/statements/select/sample
title: 'SAMPLE Clause'
doc_type: 'reference'
SAMPLE Clause
The
SAMPLE
clause allows for approximated
SELECT
query processing.
When data sampling is enabled, the query is not performed on all ... | {"source_file": "sample.md"} | [
0.007604079321026802,
0.014686215668916702,
0.02274182252585888,
0.019250022247433662,
0.013224491849541664,
-0.06004681810736656,
0.013776063919067383,
0.08362902700901031,
0.00913335382938385,
0.010164657607674599,
-0.0382855162024498,
-0.049720995128154755,
0.004954458214342594,
-0.1012... |
77b15004-3b4c-48f4-950a-7f01ca5d82b3 | For the
SAMPLE
clause the following syntax is supported:
| SAMPLEΒ ClauseΒ Syntax | Description ... | {"source_file": "sample.md"} | [
0.031813643872737885,
0.04020911455154419,
0.010421712882816792,
0.01506603229790926,
0.0010515624890103936,
0.08196666091680527,
0.028783153742551804,
0.06705045700073242,
-0.019736340269446373,
0.003211956936866045,
0.024744238704442978,
-0.09734810888767242,
0.01851629838347435,
-0.0679... |
5c7dcd47-6a38-4d72-9058-aeeb7acdc602 | Let's consider the table
visits
, which contains the statistics about site visits. The first example shows how to calculate the number of page views:
sql
SELECT sum(PageViews * _sample_factor)
FROM visits
SAMPLE 10000000
The next example shows how to calculate the total number of visits:
sql
SELECT sum(_sample_f... | {"source_file": "sample.md"} | [
0.07434920221567154,
0.011831318028271198,
-0.02848443016409874,
0.039091557264328,
-0.031348783522844315,
0.021579356864094734,
0.020971257239580154,
0.0503494031727314,
0.004555836319923401,
0.03892927244305611,
-0.02258562296628952,
-0.07367996871471405,
0.050927404314279556,
0.02710941... |
a0620b62-4d60-49ce-874a-227200610687 | description: 'Documentation for INTERSECT Clause'
sidebar_label: 'INTERSECT'
slug: /sql-reference/statements/select/intersect
title: 'INTERSECT Clause'
doc_type: 'reference'
INTERSECT Clause
The
INTERSECT
clause returns only those rows that result from both the first and the second queries. The queries must mat... | {"source_file": "intersect.md"} | [
0.02102535218000412,
-0.0045741256326437,
0.016669850796461105,
0.03501564636826515,
0.012940101325511932,
0.008059071376919746,
0.07961411029100418,
0.0196290984749794,
-0.0962236151099205,
0.0035966814029961824,
-0.007492159027606249,
-0.008124285377562046,
0.05172281339764595,
-0.054527... |
b40b8e7b-2d5a-45bf-931f-38fefc7ce794 | Now suppose we have a table named
holdings
that contains a list of cryptocurrencies that we own, along with the number of coins:
```sql
CREATE TABLE holdings
(
crypto_name String,
quantity UInt64
)
ENGINE = MergeTree
PRIMARY KEY (crypto_name);
INSERT INTO holdings VALUES
('Bitcoin', 1000),
('Bitcoin... | {"source_file": "intersect.md"} | [
0.060665931552648544,
0.03794543817639351,
-0.021057453006505966,
0.05865256115794182,
-0.04491356387734413,
-0.06565825641155243,
0.10489905625581741,
0.031321678310632706,
-0.02430880255997181,
-0.010878496803343296,
0.03499806299805641,
-0.12775413691997528,
0.07696680724620819,
-0.0509... |
c70a4f60-fe04-4f3a-a4ec-8405b9bc4ad7 | description: 'Documentation for QUALIFY Clause'
sidebar_label: 'QUALIFY'
slug: /sql-reference/statements/select/qualify
title: 'QUALIFY Clause'
doc_type: 'reference'
QUALIFY Clause
Allows filtering window functions results. It is similar to the
WHERE
clause, but the difference is that
WHERE
is performed befor... | {"source_file": "qualify.md"} | [
-0.023051846772432327,
0.0524623841047287,
0.09708321839570999,
0.03835555538535118,
0.02245139889419079,
0.07568692415952682,
0.016521023586392403,
0.11508508026599884,
-0.03530460596084595,
-0.07515505701303482,
-0.04428398609161377,
-0.06404316425323486,
0.04265745356678963,
-0.03699528... |
1529b7b3-57e3-465e-a55a-15d3eafb8f51 | description: 'Documentation for HAVING Clause'
sidebar_label: 'HAVING'
slug: /sql-reference/statements/select/having
title: 'HAVING Clause'
doc_type: 'reference'
HAVING Clause
Allows filtering the aggregation results produced by
GROUP BY
. It is similar to the
WHERE
clause, but the difference is that
WHERE
i... | {"source_file": "having.md"} | [
0.02999713085591793,
0.05698630213737488,
0.0330427922308445,
0.04457227140665054,
-0.09814178943634033,
0.05534442886710167,
0.03464999049901962,
0.0560898594558239,
-0.0374959260225296,
-0.05730443820357323,
0.003908390644937754,
-0.014451645314693451,
0.08472385257482529,
-0.01417683809... |
dee6ab90-9777-4f4a-847b-98fee0173ff5 | description: 'Documentation for the EXCEPT clause which returns only those rows that result from the first query without the second.'
sidebar_label: 'EXCEPT'
slug: /sql-reference/statements/select/except
title: 'EXCEPT clause'
keywords: ['EXCEPT', 'clause']
doc_type: 'reference'
EXCEPT clause
The
EXCEPT
claus... | {"source_file": "except.md"} | [
0.014426277950406075,
0.0662553459405899,
0.06009691208600998,
0.013944651931524277,
0.033637866377830505,
-0.01464368961751461,
0.011258949525654316,
-0.01639760285615921,
-0.042856935411691666,
-0.016232235357165337,
0.04440926015377045,
0.026127716526389122,
0.0705273449420929,
-0.17504... |
502e748c-2b6d-412d-acc5-4a7b39abb8de | ```sql title="Query"
SHOW COLUMNS IN system.settings
SELECT * EXCEPT (default, alias_for, readonly, description)
FROM system.settings
LIMIT 5
```
```response title="Response"
ββfieldββββββββ¬βtypeββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ¬βnullββ¬βkeyββ¬βdefaultββ¬βextraββ
1. β alias_for... | {"source_file": "except.md"} | [
0.04818429797887802,
-0.02215716242790222,
-0.03398711606860161,
0.03172945976257324,
-0.0459335558116436,
-0.060044847428798676,
0.003118786495178938,
0.027114376425743103,
-0.06173858046531677,
0.06833475083112717,
0.0314861424267292,
-0.049383603036403656,
0.05771927908062935,
-0.090641... |
cc1760d6-c465-4289-9227-3a2c6440909c | Using
EXCEPT
and
INTERSECT
with Cryptocurrency Data {#using-except-and-intersect-with-cryptocurrency-data}
EXCEPT
and
INTERSECT
can often be used interchangeably with different Boolean logic, and they are both useful if you have two tables that share a common column (or columns).
For example, suppose we have a... | {"source_file": "except.md"} | [
0.04362691566348076,
0.0346045196056366,
-0.06148731708526611,
0.01586286723613739,
0.04564530774950981,
-0.06339415907859802,
-0.0010237469105049968,
-0.03868424519896507,
0.0010842038318514824,
-0.022786661982536316,
0.038235705345869064,
-0.08019424974918365,
0.06475815922021866,
-0.089... |
0310d7a7-c8a8-431d-8645-dd337c20dc2b | This means of the four cryptocurrencies we own, only Bitcoin has never dropped below $10 (based on the limited data we have here in this example).
Using
EXCEPT DISTINCT
{#using-except-distinct}
Notice in the previous query we had multiple Bitcoin holdings in the result. You can add
DISTINCT
to
EXCEPT
to elimi... | {"source_file": "except.md"} | [
0.03584487736225128,
0.03181276470422745,
0.007693099323660135,
0.051712822169065475,
-0.007217647973448038,
-0.0353710800409317,
0.03861250355839729,
-0.008982319384813309,
0.038456909358501434,
-0.05412498116493225,
0.026511091738939285,
-0.06152676045894623,
0.08598044514656067,
-0.0474... |
72ab6817-5ebf-44e5-a0d9-80ad06b50222 | description: 'Documentation for PREWHERE Clause'
sidebar_label: 'PREWHERE'
slug: /sql-reference/statements/select/prewhere
title: 'PREWHERE Clause'
doc_type: 'reference'
PREWHERE Clause
Prewhere is an optimization to apply filtering more efficiently. It is enabled by default even if
PREWHERE
clause is not speci... | {"source_file": "prewhere.md"} | [
0.034815847873687744,
0.05196213349699974,
0.05206279456615448,
0.0593482181429863,
0.006178066600114107,
0.04602804407477379,
0.020909586921334267,
0.015246464870870113,
0.029807494953274727,
0.06041063368320465,
-0.0243417676538229,
0.03352678194642067,
0.014099734835326672,
-0.101796597... |
7e72356f-b080-4f8c-957f-341c87dcecf0 | -- Let's move other predicate
C = 'x'
SELECT count()
FROM mydata
PREWHERE C = 'x'
WHERE B = 0;
1 row in set. Elapsed: 0.069 sec. Processed 10.00 million rows, 158.89 MB (144.90 million rows/s., 2.30 GB/s.)
-- This query with manual
PREWHERE
processes slightly less data: 158.89 MB VS 168.89 MB
``` | {"source_file": "prewhere.md"} | [
0.10324254631996155,
0.008840871043503284,
-0.02176063321530819,
0.019611500203609467,
-0.02631288580596447,
-0.00565730594098568,
0.05530965328216553,
0.02174900844693184,
0.06975876539945602,
0.06907752901315689,
0.02189386822283268,
-0.02928377315402031,
0.034352850168943405,
-0.0684380... |
21880022-48e8-476e-88ac-7b1d2effa7e5 | description: 'Documentation describing the APPLY modifier which allows you to invoke some function for each row returned by an outer table expression of a query.'
sidebar_label: 'APPLY'
slug: /sql-reference/statements/select/apply-modifier
title: 'APPLY modifier'
keywords: ['APPLY', 'modifier']
doc_type: 'reference'
... | {"source_file": "apply_modifier.md"} | [
-0.02589486353099346,
0.033011868596076965,
-0.007465968374162912,
0.005564346443861723,
-0.025488030165433884,
-0.030023187398910522,
0.027351897209882736,
0.08163940161466599,
-0.07556484639644623,
0.05147232115268707,
0.0356806181371212,
-0.04864666983485222,
0.04611334949731827,
-0.156... |
ae2505e3-1766-4ecd-90bb-4bf4c5dfccf0 | description: 'Documentation for UNION Clause'
sidebar_label: 'UNION'
slug: /sql-reference/statements/select/union
title: 'UNION Clause'
doc_type: 'reference'
UNION Clause
You can use
UNION
with explicitly specifying
UNION ALL
or
UNION DISTINCT
.
If you don't specify
ALL
or
DISTINCT
, it will depend on t... | {"source_file": "union.md"} | [
0.021974559873342514,
0.016705334186553955,
-0.0017580728745087981,
0.10954808443784714,
-0.09422226995229721,
0.06672180444002151,
0.046541936695575714,
0.01678040809929371,
-0.012823968194425106,
0.014283494092524052,
-0.04974907264113426,
-0.03954904526472092,
0.07195354998111725,
-0.05... |
f3a7ff8f-6920-4680-9839-81f7660a2131 | description: 'Documentation describing the APPLY modifier which allows you to invoke some function for each row returned by an outer table expression of a query.'
sidebar_label: 'REPLACE'
slug: /sql-reference/statements/select/replace-modifier
title: 'Replace modifier'
keywords: ['REPLACE', 'modifier']
doc_type: 'refer... | {"source_file": "replace_modifier.md"} | [
-0.040513407438993454,
0.01674501784145832,
0.04193177446722984,
0.04172502085566521,
0.004246289376169443,
-0.02439337596297264,
0.006456258241087198,
0.02814866043627262,
-0.025363672524690628,
0.07342755049467087,
0.02437795326113701,
0.010968755930662155,
0.01967177912592888,
-0.149626... |
a06d0c97-c1c4-4fc8-94f3-12b21434ea85 | description: 'Documentation for ORDER BY Clause'
sidebar_label: 'ORDER BY'
slug: /sql-reference/statements/select/order-by
title: 'ORDER BY Clause'
doc_type: 'reference'
ORDER BY Clause
The
ORDER BY
clause contains
a list of expressions, e.g.
ORDER BY visits, search_phrase
,
a list of numbers referring t... | {"source_file": "order-by.md"} | [
0.008471833541989326,
0.012429703027009964,
0.030986832454800606,
0.02486303821206093,
-0.0444449745118618,
0.016018912196159363,
0.0026100692339241505,
-0.0048064724542200565,
0.014585406519472599,
0.09208673238754272,
0.02321453019976616,
0.17300671339035034,
0.038975607603788376,
-0.054... |
5c3fed7f-7b64-46e8-9d9c-5ad042146fb1 | Collate is supported in
LowCardinality
,
Nullable
,
Array
and
Tuple
.
We only recommend using
COLLATE
for final sorting of a small number of rows, since sorting with
COLLATE
is less efficient than normal sorting by bytes.
Collation Examples {#collation-examples}
Example only with
String
values:
Input... | {"source_file": "order-by.md"} | [
0.041718289256095886,
-0.06512418389320374,
0.016818229109048843,
0.019351260736584663,
-0.04122078791260719,
-0.01799171231687069,
0.0005868474254384637,
0.029178569093346596,
-0.07342053204774857,
0.028300810605287552,
-0.03457185998558998,
0.07456131279468536,
0.0042879958637058735,
-0.... |
823dcf70-a8dd-45bf-b1ef-0e0765a671a8 | If there is not enough RAM, it is possible to perform sorting in external memory (creating temporary files on a disk). Use the setting
max_bytes_before_external_sort
for this purpose. If it is set to 0 (the default), external sorting is disabled. If it is enabled, when the volume of data to sort reaches the specified... | {"source_file": "order-by.md"} | [
0.0036806564312428236,
-0.04072017967700958,
-0.05528739094734192,
0.04708627238869667,
-0.015213234350085258,
-0.06793882697820663,
0.02073316089808941,
0.06634437292814255,
0.002160662319511175,
0.0903133675456047,
0.04335061088204384,
0.10698556900024414,
0.030076907947659492,
-0.043732... |
925dafcf-86aa-43b6-af8c-18289a40dfa5 | To fill multiple columns, add
WITH FILL
modifier with optional parameters after each field name in
ORDER BY
section.
sql
ORDER BY expr [WITH FILL] [FROM const_expr] [TO const_expr] [STEP const_numeric_expr] [STALENESS const_numeric_expr], ... exprN [WITH FILL] [FROM expr] [TO expr] [STEP numeric_expr] [STALENESS ... | {"source_file": "order-by.md"} | [
-0.05799982324242592,
-0.006695910356938839,
-0.005347033031284809,
0.032390132546424866,
-0.0578121617436409,
-0.019862741231918335,
-0.002710344735532999,
0.0739373043179512,
-0.0854216143488884,
-0.011480000801384449,
-0.043582748621702194,
0.00417729839682579,
0.0006844557938165963,
-0... |
f245fb4c-8596-479a-95b8-55bbe0318f52 | Result:
text
ββββd1ββββββββ¬βββd2ββββββββ¬βsourceββββ
β 1970-01-11 β 1970-01-02 β original β
β 1970-01-01 β 1970-01-03 β β
β 1970-01-01 β 1970-01-04 β β
β 1970-02-10 β 1970-01-05 β original β
β 1970-01-01 β 1970-01-06 β β
β 1970-01-01 β 1970-01-07 β β
β 1970-03-12 β 1970-01-08 β orig... | {"source_file": "order-by.md"} | [
-0.10774681717157364,
0.001486922730691731,
0.1291782557964325,
-0.021180540323257446,
-0.05321882292628288,
-0.002975816372781992,
0.00984268169850111,
0.025340095162391663,
0.05779865011572838,
-0.012905415147542953,
0.0447898730635643,
0.02178393118083477,
-0.09272851049900055,
-0.09327... |
62a2dc47-e085-46a7-9df2-a992afd0c0bf | Result:
response
ββββββββββd1ββ¬βββββββββd2ββ¬βsourceββββ
β 1970-01-11 β 1970-01-02 β original β
β 1970-01-12 β 1970-01-01 β β
β 1970-01-13 β 1970-01-01 β β
β 1970-01-14 β 1970-01-01 β β
β 1970-01-15 β 1970-01-01 β β
β 1970-01-16 β 1970-01-01 β β
β 1970-01-17 β 1970-01-01 β ... | {"source_file": "order-by.md"} | [
-0.05288140848278999,
0.0580114983022213,
-0.045162998139858246,
0.03369942307472229,
-0.006575243081897497,
-0.03560882434248924,
0.03453652188181877,
0.010584820993244648,
-0.012560427188873291,
0.03942781686782837,
0.05502890795469284,
-0.00840887613594532,
0.06506778299808502,
-0.02575... |
e2852e81-d3c2-45af-8500-7eeb614da546 | Example of a query without
STALENESS
:
sql
SELECT number AS key, 5 * number value, 'original' AS source
FROM numbers(16) WHERE key % 5 == 0
ORDER BY key WITH FILL;
Result:
text
ββkeyββ¬βvalueββ¬βsourceββββ
1. β 0 β 0 β original β
2. β 1 β 0 β β
3. β 2 β 0 β β
4. β 3 β ... | {"source_file": "order-by.md"} | [
-0.0607997328042984,
-0.04791620746254921,
0.046557530760765076,
0.02164715714752674,
-0.011568472720682621,
-0.02129930444061756,
0.029340334236621857,
-0.06721470504999161,
0.018475910648703575,
0.033896736800670624,
0.04542706906795502,
0.05608070641756058,
0.0023611232172697783,
-0.117... |
e3333556-b6f9-476e-a928-5b7adaaf54fd | Filling grouped by sorting prefix {#filling-grouped-by-sorting-prefix}
It can be useful to fill rows which have the same values in particular columns independently, - a good example is filling missing values in time series.
Assume there is the following time series table:
``sql
CREATE TABLE timeseries
(
sensor_id
UI... | {"source_file": "order-by.md"} | [
-0.06527075916528702,
-0.025714140385389328,
0.06579315662384033,
0.025299128144979477,
-0.026533083990216255,
-0.02781374752521515,
0.018868762999773026,
-0.0042030601762235165,
0.009224538691341877,
0.019904350861907005,
-0.010177122429013252,
-0.007447259500622749,
-0.007618439383804798,
... |
4e991e09-184b-4ba8-b368-207aaced2f10 | description: 'Documentation for FROM Clause'
sidebar_label: 'FROM'
slug: /sql-reference/statements/select/from
title: 'FROM Clause'
doc_type: 'reference'
FROM Clause
The
FROM
clause specifies the source to read data from:
Table
Subquery
Table function
JOIN
and
ARRAY JOIN
clauses may also be use... | {"source_file": "from.md"} | [
-0.044131603091955185,
-0.004346354864537716,
0.024475300684571266,
0.061485737562179565,
0.0502002015709877,
-0.01743384823203087,
0.0518447607755661,
0.016151485964655876,
-0.018111657351255417,
-0.028691181913018227,
0.037722695618867874,
0.01645302027463913,
0.057452742010354996,
-0.15... |
c17b9824-6e87-4201-b157-684ae3c0358b | Using
FINAL
as a session-level setting
sql
SET final = 1;
SELECT x, y FROM mytable WHERE x > 1;
Implementation Details {#implementation-details}
If the
FROM
clause is omitted, data will be read from the
system.one
table.
The
system.one
table contains exactly one row (this table fulfills the same purpose a... | {"source_file": "from.md"} | [
0.0690496563911438,
-0.01704678125679493,
-0.024069633334875107,
-0.008017019368708134,
-0.05898767337203026,
-0.07217556983232498,
0.014094571582973003,
0.11244605481624603,
-0.0028573593590408564,
0.05427313223481178,
0.01788521744310856,
0.012204445898532867,
0.09075402468442917,
-0.091... |
132ec22f-9013-48e4-9e96-0816b6e8f64f | description: 'Documentation for LIMIT BY Clause'
sidebar_label: 'LIMIT BY'
slug: /sql-reference/statements/select/limit-by
title: 'LIMIT BY Clause'
doc_type: 'reference'
LIMIT BY Clause
A query with the
LIMIT n BY expressions
clause selects the first
n
rows for each distinct value of
expressions
. The key fo... | {"source_file": "limit-by.md"} | [
-0.03019314631819725,
-0.007602638099342585,
0.01964249461889267,
-0.0028092211578041315,
-0.04641837254166603,
-0.009202226996421814,
0.007056661881506443,
-0.013682706281542778,
0.001115736784413457,
0.023321647197008133,
-0.0039027214515954256,
0.05138099566102028,
0.025361694395542145,
... |
4dce8d9b-9203-42dd-9894-b4cec346a972 | For example:
sql
SELECT substring(a, 4, 2), substring(substring(a, 1, 2), 1, count(b)) FROM t LIMIT 2 BY ALL
is the same as
sql
SELECT substring(a, 4, 2), substring(substring(a, 1, 2), 1, count(b)) FROM t LIMIT 2 BY substring(a, 4, 2), substring(a, 1, 2)
Examples {#examples-limit-by-all}
Sample table:
sql
C... | {"source_file": "limit-by.md"} | [
-0.02787882089614868,
-0.03745068237185478,
-0.000992955407127738,
-0.02943672612309456,
-0.0494372621178627,
-0.013133466243743896,
0.05669501796364784,
0.009537299163639545,
0.03939474746584892,
-0.0794166848063469,
0.008502393029630184,
0.05862219259142876,
0.05549117922782898,
-0.08597... |
50d77ccf-7e2c-4e28-b7ae-9d2a2ef34891 | description: 'Documentation for GROUP BY Clause'
sidebar_label: 'GROUP BY'
slug: /sql-reference/statements/select/group-by
title: 'GROUP BY Clause'
doc_type: 'reference'
GROUP BY Clause
GROUP BY
clause switches the
SELECT
query into an aggregation mode, which works as follows:
GROUP BY
clause contains a l... | {"source_file": "group-by.md"} | [
-0.027051836252212524,
-0.02059921808540821,
0.049669697880744934,
0.07471103221178055,
0.0073620774783194065,
0.05066389963030815,
-0.0036190703976899385,
0.020080141723155975,
0.09422264993190765,
0.02208099327981472,
0.03303489089012146,
0.081475168466568,
0.03073546662926674,
-0.097442... |
423ec503-d824-4402-bff2-72de65f27953 | :::note
Mind that
HAVING
clause can affect the subtotals results.
:::
Example
Consider the table t:
text
ββyearββ¬βmonthββ¬βdayββ
β 2019 β 1 β 5 β
β 2019 β 1 β 15 β
β 2020 β 1 β 5 β
β 2020 β 1 β 15 β
β 2020 β 10 β 5 β
β 2020 β 10 β 15 β
ββββββββ΄ββββββββ΄ββββββ
Query:
sql
SELECT y... | {"source_file": "group-by.md"} | [
-0.005622030235826969,
0.0974152684211731,
0.02275817282497883,
0.035124555230140686,
-0.05990835279226303,
0.016383491456508636,
0.031133996322751045,
-0.020211301743984222,
-0.012864869087934494,
0.04767569899559021,
0.11227893829345703,
-0.07516274601221085,
0.023501606658101082,
-0.052... |
1161b474-4f6a-4e85-b812-1af846810bdb | GROUP BY year, month
GROUP BY year, day
GROUP BY year
GROUP BY month, day
GROUP BY month
GROUP BY day
and totals.
Columns, excluded from
GROUP BY
, are filled with zeros.
text
ββyearββ¬βmonthββ¬βdayββ¬βcount()ββ
β 2020 β 10 β 15 β 1 β
β 2020 β 1 β 5 β 1 β
β 2019 β 1 β 5 β ... | {"source_file": "group-by.md"} | [
0.023802345618605614,
0.06008581817150116,
-0.014988154172897339,
0.06256067752838135,
-0.014798177406191826,
-0.04115213826298714,
0.017447270452976227,
-0.05898895487189293,
-0.009861582890152931,
0.04230833426117897,
0.12036066502332687,
-0.09752529114484787,
0.004124304745346308,
-0.02... |
d7b1c0e8-01e7-44b5-8b3a-7126aadbd857 | WITH TOTALS
can be run in different ways when
HAVING
is present. The behavior depends on the
totals_mode
setting.
Configuring Totals Processing {#configuring-totals-processing}
By default,
totals_mode = 'before_having'
. In this case, 'totals' is calculated across all rows, including the ones that do not pass... | {"source_file": "group-by.md"} | [
-0.05341167375445366,
-0.00340264686383307,
0.02043088525533676,
-0.01757722906768322,
-0.017723448574543,
-0.03478208929300308,
-0.022426115348935127,
-0.04229985550045967,
-0.0495033860206604,
0.03502530977129936,
0.06840980052947998,
0.004692540969699621,
0.03608211502432823,
-0.0370055... |
6d6a56a4-bb31-4570-be57-eb674f9684bf | Example:
sql
SELECT
domainWithoutWWW(URL) AS domain,
count(),
any(Title) AS title -- getting the first occurred page header for each domain.
FROM hits
GROUP BY domain
For every different key value encountered,
GROUP BY
calculates a set of aggregate function values.
GROUPING SETS modifier {#grouping-... | {"source_file": "group-by.md"} | [
-0.06239568442106247,
-0.045630648732185364,
-0.06807498633861542,
0.06478872150182724,
-0.013294401578605175,
-0.06203548237681389,
-0.03838738054037094,
-0.04009125754237175,
0.06474479287862778,
-0.036314256489276886,
0.015599912963807583,
-0.027403000742197037,
0.06535661965608597,
-0.... |
aa84e25e-9e49-4ba9-838b-9c66499cfb0a | GROUP BY in External Memory {#group-by-in-external-memory}
You can enable dumping temporary data to the disk to restrict memory usage during
GROUP BY
.
The
max_bytes_before_external_group_by
setting determines the threshold RAM consumption for dumping
GROUP BY
temporary data to the file system. If set to 0 (the ... | {"source_file": "group-by.md"} | [
0.019364912062883377,
0.001840272918343544,
-0.07301407307386398,
0.07915805280208588,
-0.028070902451872826,
-0.08158156275749207,
0.02719530090689659,
0.08088938891887665,
0.01455411221832037,
0.034621112048625946,
0.025881614536046982,
0.0464584082365036,
0.036820124834775925,
-0.031982... |
314b2421-fd47-4fe7-b983-02da5d2a6976 | description: 'Documentation for SELECT Query'
sidebar_label: 'SELECT'
sidebar_position: 32
slug: /sql-reference/statements/select/
title: 'SELECT Query'
doc_type: 'reference'
SELECT Query
SELECT
queries perform data retrieval. By default, the requested data is returned to the client, while in conjunction with
I... | {"source_file": "index.md"} | [
-0.0006823174771852791,
0.03882407397031784,
0.023248160257935524,
0.04061656445264816,
-0.021455654874444008,
-0.00801974069327116,
0.05335298180580139,
0.08604602515697479,
-0.04033266007900238,
-0.002691259840503335,
0.05576296150684357,
-0.03814414516091347,
0.10589510202407837,
-0.143... |
010446ea-ec99-4bcf-bdf5-b7169be53dce | The selected columns are returned not in the alphabetical order.
You can use multiple
COLUMNS
expressions in a query and apply functions to them.
For example:
sql
SELECT COLUMNS('a'), COLUMNS('c'), toTypeName(COLUMNS('c')) FROM col_names
text
ββaaββ¬βabββ¬βbcββ¬βtoTypeName(bc)ββ
β 1 β 1 β 1 β Int8 β... | {"source_file": "index.md"} | [
0.023774337023496628,
-0.05705711245536804,
-0.06198832020163536,
0.04962846636772156,
-0.07225904613733292,
-0.023325402289628983,
0.0017639697762206197,
-0.0216839462518692,
-0.023439982905983925,
0.047654278576374054,
0.0488254576921463,
-0.023728925734758377,
0.03407745435833931,
-0.10... |
c1970df9-f283-4e2d-875b-32809749e6d3 | In
JSON*
and
XML
formats, the extreme values are output in a separate 'extremes' field. In
TabSeparated*
,
CSV*
and
Vertical
formats, the row comes after the main result, and after 'totals' if present. It is preceded by an empty row (after the other data). In
Pretty*
formats, the row is output as a separate ... | {"source_file": "index.md"} | [
-0.030989451333880424,
0.054886505007743835,
-0.02403460070490837,
-0.03994227573275566,
-0.03268027305603027,
-0.02459915354847908,
-0.07064348459243774,
0.10113737732172012,
0.010013410821557045,
-0.019318370148539543,
0.033183593302965164,
0.014741189777851105,
0.022922508418560028,
0.0... |
1992af06-5fe2-4826-8050-e282222c8b06 | SELECT modifiers {#select-modifiers}
You can use the following modifiers in
SELECT
queries.
| Modifier | Description ... | {"source_file": "index.md"} | [
0.04998774826526642,
0.02536751516163349,
0.03665660321712494,
0.07416611909866333,
-0.005894958507269621,
-0.029735572636127472,
0.05307158827781677,
-0.002783537609502673,
0.031131871044635773,
-0.014711595140397549,
0.0192811768501997,
-0.11420664936304092,
0.04384550824761391,
-0.08291... |
2a38db11-dacc-4e16-80b2-9e9c40293a13 | You can specify the necessary settings right in the
SELECT
query. The setting value is applied only to this query and is reset to default or previous value after the query is executed.
Other ways to make settings see
here
.
For boolean settings set to true, you can use a shorthand syntax by omitting the value as... | {"source_file": "index.md"} | [
0.04918712005019188,
-0.01372440718114376,
-0.019023189321160316,
0.09641806036233902,
-0.12185704708099365,
0.04649181663990021,
0.05579233914613724,
-0.029121462255716324,
-0.05636867880821228,
0.03814224898815155,
0.015108577907085419,
0.02028118073940277,
0.035999927669763565,
-0.07243... |
0ebb10b3-6fa6-4179-8365-a5c1db181236 | description: 'Documentation for WITH Clause'
sidebar_label: 'WITH'
slug: /sql-reference/statements/select/with
title: 'WITH Clause'
doc_type: 'reference'
WITH Clause
ClickHouse supports Common Table Expressions (
CTE
), Common Scalar Expressions and Recursive Queries.
Common Table Expressions {#common-table-exp... | {"source_file": "with.md"} | [
-0.0703301951289177,
-0.009428526274859905,
0.05678858980536461,
0.06133691966533661,
-0.05399675667285919,
0.009161893278360367,
0.05964988097548485,
0.04096049815416336,
-0.0018975057173520327,
-0.0010005871299654245,
-0.01811133325099945,
-0.03845112398266792,
0.06959160417318344,
-0.06... |
5a225203-5285-4ae5-a876-08526066dd98 | sql
WITH
'.txt' as extension,
(id, extension) -> concat(lower(id), extension) AS gen_name
SELECT gen_name('test', '.sql') as file_name;
response
ββfile_nameββ
1. β test.sql β
βββββββββββββ
Example 3:
Using higher-order functions with free variables
The following example queries show that unbound i... | {"source_file": "with.md"} | [
-0.07241728156805038,
0.02607712522149086,
-0.03964051231741905,
0.08743271976709366,
-0.002063826657831669,
-0.051376085728406906,
0.070426806807518,
0.08153535425662994,
-0.007605068851262331,
0.012795746326446533,
0.10426267981529236,
0.006143351551145315,
0.05036396533250809,
-0.069745... |
2bf2ad83-98e7-4d22-8a4d-86f966a1c60a | The general form of a recursive
WITH
query is always a non-recursive term, then
UNION ALL
, then a recursive term, where only the recursive term can contain a reference to the query's own output. Recursive CTE query is executed as follows:
Evaluate the non-recursive term. Place result of non-recursive term query... | {"source_file": "with.md"} | [
-0.0000507932563778013,
-0.04008783772587776,
0.029336925595998764,
0.0251372791826725,
-0.10016057640314102,
-0.08395110815763474,
-0.009278432466089725,
0.02939934842288494,
-0.0033317289780825377,
0.06003495678305626,
-0.016369814053177834,
-0.05631294846534729,
0.03691994771361351,
-0.... |
cd0cb9da-b9ec-488e-92c3-5ba55d985eed | text
ββidββ¬βlinkββ¬βdataβββββββ¬βpathβββββ¬βdepthββ
β 0 β α΄Ία΅α΄Έα΄Έ β ROOT β [0] β 0 β
β 1 β 0 β Child_1 β [0,1] β 1 β
β 2 β 0 β Child_2 β [0,2] β 1 β
β 3 β 1 β Child_1_1 β [0,1,3] β 2 β
ββββββ΄βββββββ΄ββββββββββββ΄ββββββββββ΄ββββββββ
Cycle detection {#cycle-detection}
First let's ... | {"source_file": "with.md"} | [
-0.00003533618655637838,
0.008397642523050308,
0.016595283523201942,
-0.008717167191207409,
-0.01868511736392975,
-0.03833123669028282,
-0.012155305594205856,
-0.022005796432495117,
-0.04767388105392456,
0.049527931958436966,
0.06194266676902771,
-0.0057809907011687756,
0.05546236038208008,
... |
e26b994b-3674-4f2b-b859-64df9a633827 | Infinite queries {#infinite-queries}
It is also possible to use infinite recursive CTE queries if
LIMIT
is used in outer query:
Example:
Infinite recursive CTE query
sql
WITH RECURSIVE test_table AS (
SELECT 1 AS number
UNION ALL
SELECT number + 1 FROM test_table
)
SELECT sum(number) FROM (SELECT number... | {"source_file": "with.md"} | [
-0.06438058614730835,
-0.020557653158903122,
-0.007103267125785351,
0.04821081832051277,
-0.11134037375450134,
-0.04580514878034592,
0.05298866331577301,
0.018600521609187126,
0.007303787861019373,
0.038661666214466095,
-0.012771619483828545,
-0.018142318353056908,
0.027309922501444817,
-0... |
54233668-7f6c-42cd-9c3e-30d9120379f0 | description: 'Documentation for DISTINCT Clause'
sidebar_label: 'DISTINCT'
slug: /sql-reference/statements/select/distinct
title: 'DISTINCT Clause'
doc_type: 'reference'
DISTINCT Clause
If
SELECT DISTINCT
is specified, only unique rows will remain in a query result. Thus, only a single row will remain out of al... | {"source_file": "distinct.md"} | [
-0.007900556549429893,
-0.039519939571619034,
0.022971119731664658,
-0.019225461408495903,
0.007450864650309086,
0.04440763220191002,
0.03096441738307476,
-0.01806783117353916,
0.0017892669420689344,
-0.010778422467410564,
0.030782533809542656,
0.039356209337711334,
0.04556339979171753,
-0... |
ca6e7769-eb86-4903-90e8-a0534f10283d | description: 'Documentation for FORMAT Clause'
sidebar_label: 'FORMAT'
slug: /sql-reference/statements/select/format
title: 'FORMAT Clause'
doc_type: 'reference'
FORMAT Clause
ClickHouse supports a wide range of
serialization formats
that can be used on query results among other things. There are multiple ways ... | {"source_file": "format.md"} | [
0.002154534449800849,
0.005123646929860115,
-0.06962674856185913,
0.043412819504737854,
-0.0934966579079628,
0.019086642190814018,
0.0032803870271891356,
0.0623021125793457,
-0.0007655380177311599,
0.002431947272270918,
-0.009935087524354458,
0.006138952448964119,
0.052303288131952286,
-0.... |
311821f7-7978-4fc0-97d7-4cd4cf256804 | description: 'Documentation describing the EXCEPT modifier which specifies the names of one or more columns to exclude from the result. All matching column names are omitted from the output.'
sidebar_label: 'EXCEPT'
slug: /sql-reference/statements/select/except-modifier
title: 'EXCEPT modifier'
keywords: ['EXCEPT', 'mo... | {"source_file": "except_modifier.md"} | [
-0.040786921977996826,
0.06473354995250702,
0.008680199272930622,
0.048852089792490005,
0.050383973866701126,
-0.06639272719621658,
0.0173154566437006,
0.02317049168050289,
-0.03567570075392723,
-0.011253316886723042,
0.05055858567357063,
-0.012399095110595226,
0.09680022299289703,
-0.1765... |
09c131cb-a5cc-4c14-a6af-c93079a3fe13 | description: 'Documentation for JOIN Clause'
sidebar_label: 'JOIN'
slug: /sql-reference/statements/select/join
title: 'JOIN Clause'
keywords: ['INNER JOIN', 'LEFT JOIN', 'LEFT OUTER JOIN', 'RIGHT JOIN', 'RIGHT OUTER JOIN', 'FULL OUTER JOIN', 'CROSS JOIN', 'LEFT SEMI JOIN', 'RIGHT SEMI JOIN', 'LEFT ANTI JOIN', 'RIGHT AN... | {"source_file": "join.md"} | [
-0.03219868987798691,
-0.01960248313844204,
0.0034668459556996822,
0.09867966175079346,
-0.016804784536361694,
-0.020358271896839142,
0.043059803545475006,
0.08153475075960159,
-0.07541480660438538,
-0.016956547275185585,
0.048997294157743454,
0.008073505014181137,
0.08665632456541061,
-0.... |
bc934dee-8607-439f-aeec-c31b84f50df2 | An alternative syntax for
CROSS JOIN
is specifying multiple tables in the
FROM
clause
separated by commas.
Additional join types available in ClickHouse are:
| Type | Description ... | {"source_file": "join.md"} | [
0.024844208732247353,
0.01962646096944809,
0.018324242904782295,
-0.0037101733032613993,
0.0014554713852703571,
0.03723110631108284,
0.014490216039121151,
-0.012444608844816685,
-0.08937906473875046,
0.010737611912190914,
0.030662858858704567,
-0.0704628974199295,
0.05078592523932457,
-0.0... |
d6de1c55-abc0-4f2c-aeb7-2c4b579abb2c | An
ON
section can contain several conditions combined using the
AND
and
OR
operators. Conditions specifying join keys must:
- reference both left and right tables
- use the equality operator
Other conditions may use other logical operators but they must reference either the left or the right table of a query.
... | {"source_file": "join.md"} | [
-0.03883294761180878,
0.050171878188848495,
-0.012253282591700554,
0.06928740441799164,
0.054124124348163605,
-0.020196152850985527,
0.021368365734815598,
-0.024248015135526657,
0.009176856838166714,
0.00024163264606613666,
0.013255417346954346,
0.019529303535819054,
0.0963774248957634,
-0... |
f3d8c815-55c6-4f62-a8e1-464ccee52eb4 | Query with
INNER
type of a join and conditions with
OR
and
AND
:
:::note
By default, non-equal conditions are supported as long as they use columns from the same table.
For example,
t1.a = t2.key AND t1.b > 0 AND t2.b > t2.c
, because
t1.b > 0
uses columns only from
t1
and
t2.b > t2.c
uses columns only ... | {"source_file": "join.md"} | [
-0.03583761677145958,
0.017546620219945908,
0.046164751052856445,
-0.022201117128133774,
-0.049222446978092194,
-0.0652860626578331,
0.04074306786060333,
-0.015508671291172504,
-0.029095826670527458,
-0.004721359349787235,
0.011599007993936539,
-0.061106014996767044,
0.07524395734071732,
0... |
b6f87467-d6dd-4495-9482-bc0925acfb71 | sql
SELECT A.name, B.score FROM A LEFT JOIN B ON A.id = B.id
response
ββnameβββββ¬βscoreββ
β Alice β 90 β
β Bob β 0 β
β Charlie β 0 β
βββββββββββ΄ββββββββ
Notice that the row with
Charlie
from table
A
and the row with score 88 from table
B
are not in the result because of the
NULL
value in th... | {"source_file": "join.md"} | [
-0.05329185724258423,
0.043276768177747726,
-0.054166652262210846,
0.018726933747529984,
-0.01217726431787014,
0.06583748012781143,
0.05017300695180893,
0.05129959061741829,
-0.0336429588496685,
0.006521277129650116,
-0.0027520444709807634,
0.0027209443505853415,
0.11252415925264359,
-0.10... |
15a8f880-c377-4038-aae6-8e590e64fcc5 | :::note
ASOF JOIN
is supported only by
hash
and
full_sorting_merge
join algorithms.
It's
not
supported in the
Join
table engine.
:::
PASTE JOIN usage {#paste-join-usage}
The result of
PASTE JOIN
is a table that contains all columns from left subquery followed by all columns from the right subquery.
The ... | {"source_file": "join.md"} | [
-0.06930805742740631,
-0.04114183038473129,
0.03697434812784195,
-0.013396667316555977,
-0.05106579512357712,
-0.015080527402460575,
-0.015285509638488293,
-0.015430958941578865,
-0.031690966337919235,
-0.005357617978006601,
0.023579223081469536,
0.07124806940555573,
0.04200507700443268,
-... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.