summaryrefslogtreecommitdiffstats
path: root/www/syntax/common-table-expression.html
blob: 6012ae39afb11edf22d03f1b56b4c48e4f2ad48c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../sqlite.css" rel="stylesheet">
<title>SQLite Syntax: common-table-expression</title>
<!-- path=../ -->
</head>
<body>
<div class=nosearch>
<a href="../index.html">
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0">
</a>
<div><!-- IE hack to prevent disappearing logo --></div>
<div class="tagline desktoponly">
Small. Fast. Reliable.<br>Choose any three.
</div>
<div class="menu mainmenu">
<ul>
<li><a href="../index.html">Home</a>
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
<li class='wideonly'><a href='../about.html'>About</a>
<li class='desktoponly'><a href="../docs.html">Documentation</a>
<li class='desktoponly'><a href="../download.html">Download</a>
<li class='wideonly'><a href='../copyright.html'>License</a>
<li class='desktoponly'><a href="../support.html">Support</a>
<li class='desktoponly'><a href="../prosupport.html">Purchase</a>
<li class='search' id='search_menubutton'>
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
</ul>
</div>
<div class="menu submenu" id="submenu">
<ul>
<li><a href='../about.html'>About</a>
<li><a href='../docs.html'>Documentation</a>
<li><a href='../download.html'>Download</a>
<li><a href='../support.html'>Support</a>
<li><a href='../prosupport.html'>Purchase</a>
</ul>
</div>
<div class="searchmenu" id="searchmenu">
<form method="GET" action="../search">
<select name="s" id="searchtype">
<option value="d">Search Documentation</option>
<option value="c">Search Changelog</option>
</select>
<input type="text" name="q" id="searchbox" value="">
<input type="submit" value="Go">
</form>
</div>
</div>
<script>
function toggle_div(nm) {
var w = document.getElementById(nm);
if( w.style.display=="block" ){
w.style.display = "none";
}else{
w.style.display = "block";
}
}
function toggle_search() {
var w = document.getElementById("searchmenu");
if( w.style.display=="block" ){
w.style.display = "none";
} else {
w.style.display = "block";
setTimeout(function(){
document.getElementById("searchbox").focus()
}, 30);
}
}
function div_off(nm){document.getElementById(nm).style.display="none";}
window.onbeforeunload = function(e){div_off("submenu");}
/* Disable the Search feature if we are not operating from CGI, since */
/* Search is accomplished using CGI and will not work without it. */
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
document.getElementById("search_menubutton").style.display = "none";
}
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
var antiRobot = 0;
function antiRobotGo(){
if( antiRobot!=3 ) return;
antiRobot = 7;
var j = document.getElementById("mtimelink");
if(j && j.hasAttribute("data-href")) j.href=j.getAttribute("data-href");
}
function antiRobotDefense(){
document.body.onmousedown=function(){
antiRobot |= 2;
antiRobotGo();
document.body.onmousedown=null;
}
document.body.onmousemove=function(){
antiRobot |= 2;
antiRobotGo();
document.body.onmousemove=null;
}
setTimeout(function(){
antiRobot |= 1;
antiRobotGo();
}, 100)
antiRobotGo();
}
antiRobotDefense();
</script>
<h1 align='center'>common-table-expression</h1>
<div class='imgcontainer'>
<div style="max-width:638px"><svg xmlns='http://www.w3.org/2000/svg' class="pikchr" viewBox="0 0 638.525 167.4">
<circle cx="5" cy="29" r="3.6"  style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" />
<polygon points="32,29 20,33 20,24" style="fill:rgb(0,0,0)"/>
<path d="M9,29L26,29"  style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" />
<path d="M47,44L122,44A15 15 0 0 0 137 29A15 15 0 0 0 122 14L47,14A15 15 0 0 0 32 29A15 15 0 0 0 47 44Z"  style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" />
<text x="85" y="29" text-anchor="middle" fill="rgb(0,0,0)" dominant-baseline="central">table-name</text>
<polygon points="160,29 149,33 149,24" style="fill:rgb(0,0,0)"/>
<path d="M137,29L155,29"  style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" />
<polygon points="196,29 185,33 185,24" style="fill:rgb(0,0,0)"/>
<path d="M160,29L191,29"  style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" />
<path d="M211,44A15 15 0 0 0 227 29A15 15 0 0 0 211 14A15 15 0 0 0 196 29A15 15 0 0 0 211 44Z"  style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" />
<text x="211" y="29" text-anchor="middle" font-weight="bold" fill="rgb(0,0,0)" dominant-baseline="central">(</text>
<polygon points="250,29 238,33 238,24" style="fill:rgb(0,0,0)"/>
<path d="M227,29L244,29"  style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" />
<polygon points="286,29 274,33 274,24" style="fill:rgb(0,0,0)"/>
<path d="M250,29L280,29"  style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" />
<path d="M301,44L395,44A15 15 0 0 0 410 29A15 15 0 0 0 395 14L301,14A15 15 0 0 0 286 29A15 15 0 0 0 301 44Z"  style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" />
<text x="348" y="29" text-anchor="middle" fill="rgb(0,0,0)" dominant-baseline="central">column-name</text>
<polygon points="446,29 434,33 434,24" style="fill:rgb(0,0,0)"/>
<path d="M410,29L440,29"  style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" />
<path d="M461,44A15 15 0 0 0 476 29A15 15 0 0 0 461 14A15 15 0 0 0 446 29A15 15 0 0 0 461 44Z"  style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" />
<text x="461" y="29" text-anchor="middle" font-weight="bold" fill="rgb(0,0,0)" dominant-baseline="central">)</text>
<polygon points="511,29 499,33 499,24" style="fill:rgb(0,0,0)"/>
<path d="M476,29L505,29"  style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" />
<path d="M47,165L51,165A15 15 0 0 0 66 150A15 15 0 0 0 51 135L47,135A15 15 0 0 0 32 150A15 15 0 0 0 47 165Z"  style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" />
<text x="49" y="150" text-anchor="middle" fill="rgb(0,0,0)" dominant-baseline="central">AS</text>
<path d="M127,135L147,135A15 15 0 0 0 162 119A15 15 0 0 0 147 104L127,104A15 15 0 0 0 112 119A15 15 0 0 0 127 135Z"  style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" />
<text x="137" y="119" text-anchor="middle" fill="rgb(0,0,0)" dominant-baseline="central">NOT</text>
<path d="M219,135L337,135A15 15 0 0 0 352 119A15 15 0 0 0 337 104L219,104A15 15 0 0 0 204 119A15 15 0 0 0 219 135Z"  style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" />
<text x="278" y="119" text-anchor="middle" fill="rgb(0,0,0)" dominant-baseline="central">MATERIALIZED</text>
<path d="M162,119L204,119"  style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" />
<path d="M410,165A15 15 0 0 0 425 150A15 15 0 0 0 410 135A15 15 0 0 0 395 150A15 15 0 0 0 410 165Z"  style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" />
<text x="410" y="150" text-anchor="middle" font-weight="bold" fill="rgb(0,0,0)" dominant-baseline="central">(</text>
<polygon points="448,150 437,154 437,145" style="fill:rgb(0,0,0)"/>
<path d="M425,150L442,150"  style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" />
<path d="M448,165L552,165L552,135L448,135Z"  style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" />
<text x="500" y="150" text-anchor="middle" fill="rgb(0,0,0)" dominant-baseline="central">select-stmt</text>
<polygon points="575,150 564,154 564,145" style="fill:rgb(0,0,0)"/>
<path d="M552,150L570,150"  style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" />
<path d="M591,165A15 15 0 0 0 606 150A15 15 0 0 0 591 135A15 15 0 0 0 575 150A15 15 0 0 0 591 165Z"  style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" />
<text x="591" y="150" text-anchor="middle" font-weight="bold" fill="rgb(0,0,0)" dominant-baseline="central">)</text>
<polygon points="629,150 617,154 617,145" style="fill:rgb(0,0,0)"/>
<path d="M606,150L623,150"  style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" />
<circle cx="632" cy="150" r="3.6"  style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" />
<path d="M348,82A15 15 0 0 0 363 66A15 15 0 0 0 348 51A15 15 0 0 0 333 66A15 15 0 0 0 348 82Z"  style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" />
<text x="348" y="66" text-anchor="middle" font-weight="bold" fill="rgb(0,0,0)" dominant-baseline="central">,</text>
<polygon points="363,66 374,62 374,71" style="fill:rgb(0,0,0)"/>
<path d="M410,29 L 417,29 Q 425,29 425,44 L 425,51 Q 425,66 410,66 L 384,66 L 369,66"  style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" />
<path d="M333,66 L 278,66 Q 263,66 263,51 L 263,44 Q 263,29 270,29 L 278,29"  style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" />
<polygon points="66,93 78,89 78,97" style="fill:rgb(0,0,0)"/>
<path d="M511,29 L 516,29 Q 522,29 522,44 L 522,78 Q 522,93 507,93 L 87,93 L 72,93"  style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" />
<polygon points="32,150 20,154 20,145" style="fill:rgb(0,0,0)"/>
<path d="M66,93 L 30,93 Q 15,93 15,108 L 15,135 Q 15,150 20,150 L 26,150"  style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" />
<polygon points="85,150 73,154 73,145" style="fill:rgb(0,0,0)"/>
<path d="M66,150L79,150"  style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" />
<polygon points="112,119 101,124 101,115" style="fill:rgb(0,0,0)"/>
<path d="M85,150 L 89,150 Q 92,150 92,135 L 92,134 Q 92,119 99,119 L 106,119"  style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" />
<polygon points="204,119 192,124 192,115" style="fill:rgb(0,0,0)"/>
<path d="M66,150 L 147,150 Q 162,150 170,150 Q 177,150 177,135 L 177,134 Q 177,119 188,119 L 198,119"  style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" />
<polygon points="395,150 383,154 383,145" style="fill:rgb(0,0,0)"/>
<path d="M352,119 L 360,119 Q 367,119 367,134 L 367,135 Q 367,150 378,150 L 389,150"  style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" />
<path d="M66,150L395,150"  style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" />
<polygon points="348,6 336,10 336,2" style="fill:rgb(0,0,0)"/>
<path d="M160,29 L 168,29 Q 175,29 175,17 Q 175,6 190,6 L 327,6 L 342,6"  style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" />
<path d="M348,6 L 473,6 Q 488,6 488,17 Q 488,29 495,29 L 503,29"  style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" />
</svg>
</div><br>

Used by:&nbsp;&nbsp; <a href='./compound-select-stmt.html'>compound-select-stmt</a>&nbsp;&nbsp; <a href='./delete-stmt.html'>delete-stmt</a>&nbsp;&nbsp; <a href='./delete-stmt-limited.html'>delete-stmt-limited</a>&nbsp;&nbsp; <a href='./factored-select-stmt.html'>factored-select-stmt</a>&nbsp;&nbsp; <a href='./insert-stmt.html'>insert-stmt</a>&nbsp;&nbsp; <a href='./select-stmt.html'>select-stmt</a>&nbsp;&nbsp; <a href='./simple-select-stmt.html'>simple-select-stmt</a>&nbsp;&nbsp; <a href='./update-stmt.html'>update-stmt</a>&nbsp;&nbsp; <a href='./update-stmt-limited.html'>update-stmt-limited</a><br></br>
References:&nbsp;&nbsp; <a href='./select-stmt.html'>select-stmt</a><br></br>
See also:&nbsp;&nbsp; <a href='../lang_aggfunc.html'>lang_aggfunc.html</a>&nbsp;&nbsp; <a href='../lang_altertable.html'>lang_altertable.html</a>&nbsp;&nbsp; <a href='../lang_attach.html'>lang_attach.html</a>&nbsp;&nbsp; <a href='../lang_createindex.html'>lang_createindex.html</a>&nbsp;&nbsp; <a href='../lang_createtable.html'>lang_createtable.html</a>&nbsp;&nbsp; <a href='../lang_createtrigger.html'>lang_createtrigger.html</a>&nbsp;&nbsp; <a href='../lang_createview.html'>lang_createview.html</a>&nbsp;&nbsp; <a href='../lang_delete.html'>lang_delete.html</a>&nbsp;&nbsp; <a href='../lang_expr.html'>lang_expr.html</a>&nbsp;&nbsp; <a href='../lang_insert.html'>lang_insert.html</a>&nbsp;&nbsp; <a href='../lang_returning.html'>lang_returning.html</a>&nbsp;&nbsp; <a href='../lang_select.html'>lang_select.html</a>&nbsp;&nbsp; <a href='../lang_update.html'>lang_update.html</a>&nbsp;&nbsp; <a href='../lang_upsert.html'>lang_upsert.html</a>&nbsp;&nbsp; <a href='../lang_with.html'>lang_with.html</a>&nbsp;&nbsp; <a href='../partialindex.html'>partialindex.html</a>
</div>