<s>
The	O
SQL	B-Language
SELECT	I-Language
statement	O
returns	O
a	O
result	B-Application
set	I-Application
of	O
records	O
,	O
from	B-Language
one	O
or	O
more	O
tables	B-Application
.	O
</s>
<s>
A	O
SELECT	O
statement	O
retrieves	O
zero	O
or	O
more	O
rows	O
from	B-Language
one	O
or	O
more	O
database	B-Application
tables	I-Application
or	O
database	B-Language
views	I-Language
.	O
</s>
<s>
In	O
most	O
applications	O
,	O
SELECT	O
is	O
the	O
most	O
commonly	O
used	O
data	B-Language
manipulation	I-Language
language	I-Language
(	O
DML	O
)	O
command	O
.	O
</s>
<s>
As	B-Language
SQL	B-Language
is	O
a	O
declarative	B-Language
programming	I-Language
language	I-Language
,	O
SELECT	O
queries	B-Language
specify	O
a	O
result	B-Application
set	I-Application
,	O
but	O
do	O
not	O
specify	O
how	O
to	O
calculate	O
it	O
.	O
</s>
<s>
The	O
database	O
translates	O
the	O
query	B-Language
into	O
a	O
"	O
query	B-Language
plan	I-Language
"	O
which	O
may	O
vary	O
between	O
executions	O
,	O
database	O
versions	O
and	O
database	O
software	O
.	O
</s>
<s>
This	O
functionality	O
is	O
called	O
the	O
"	O
query	B-Language
optimizer	I-Language
"	O
as	B-Language
it	O
is	O
responsible	O
for	O
finding	O
the	O
best	O
possible	O
execution	B-Language
plan	I-Language
for	O
the	O
query	B-Language
,	O
within	O
applicable	O
constraints	O
.	O
</s>
<s>
SELECT	O
clause	O
is	O
the	O
list	O
of	O
columns	B-Application
or	O
SQL	B-Language
expressions	O
that	O
must	O
be	O
returned	O
by	O
the	O
query	B-Language
.	O
</s>
<s>
This	O
is	O
approximately	O
the	O
relational	B-Algorithm
algebra	I-Algorithm
projection	B-Algorithm
operation	O
.	O
</s>
<s>
AS	B-Language
optionally	O
provides	O
an	O
alias	B-Language
for	O
each	O
column	O
or	O
expression	O
in	O
the	O
SELECT	O
clause	O
.	O
</s>
<s>
This	O
is	O
the	O
relational	B-Algorithm
algebra	I-Algorithm
rename	O
operation	O
.	O
</s>
<s>
FROM	B-Language
specifies	O
from	B-Language
which	O
table	B-Application
to	O
get	O
the	O
data	O
.	O
</s>
<s>
WHERE	B-Language
specifies	O
which	O
rows	O
to	O
retrieve	O
.	O
</s>
<s>
This	O
is	O
approximately	O
the	O
relational	B-Algorithm
algebra	I-Algorithm
selection	B-Algorithm
operation	O
.	O
</s>
<s>
GROUP	B-Language
BY	I-Language
groups	O
rows	O
sharing	O
a	O
property	O
so	O
that	O
an	O
aggregate	O
function	O
can	O
be	O
applied	O
to	O
each	O
group	O
.	O
</s>
<s>
HAVING	B-Language
selects	O
among	O
the	O
groups	O
defined	O
by	O
the	O
GROUP	B-Language
BY	I-Language
clause	O
.	O
</s>
<s>
ORDER	B-Language
BY	I-Language
specifies	O
how	O
to	O
order	O
the	O
returned	O
rows	O
.	O
</s>
<s>
SELECT	O
is	O
the	O
most	O
common	O
operation	O
in	O
SQL	B-Language
,	O
called	O
"	O
the	O
query	B-Language
"	O
.	O
</s>
<s>
SELECT	O
retrieves	O
data	O
from	B-Language
one	O
or	O
more	O
tables	B-Application
,	O
or	O
expressions	O
.	O
</s>
<s>
Some	O
non-standard	O
implementations	O
of	O
SELECT	O
can	O
have	O
persistent	O
effects	O
,	O
such	O
as	B-Language
the	O
SELECT	O
INTO	O
syntax	O
provided	O
in	O
some	O
databases	B-Application
.	O
</s>
<s>
Queries	B-Language
allow	O
the	O
user	O
to	O
describe	O
desired	O
data	O
,	O
leaving	O
the	O
database	B-Application
management	I-Application
system	I-Application
(	O
DBMS	O
)	O
to	O
carry	O
out	O
planning	B-Language
,	O
optimizing	B-Language
,	O
and	O
performing	O
the	O
physical	O
operations	O
necessary	O
to	O
produce	O
that	O
result	O
as	B-Language
it	O
chooses	O
.	O
</s>
<s>
A	O
query	B-Language
includes	O
a	O
list	O
of	O
columns	B-Application
to	O
include	O
in	O
the	O
final	O
result	O
,	O
normally	O
immediately	O
following	O
the	O
SELECT	O
keyword	O
.	O
</s>
<s>
An	O
asterisk	O
("*"	O
)	O
can	O
be	O
used	O
to	O
specify	O
that	O
the	O
query	B-Language
should	O
return	O
all	O
columns	B-Application
of	O
the	O
queried	O
tables	B-Application
.	O
</s>
<s>
SELECT	O
is	O
the	O
most	O
complex	O
statement	O
in	O
SQL	B-Language
,	O
with	O
optional	O
keywords	O
and	O
clauses	O
that	O
include	O
:	O
</s>
<s>
The	O
FROM	B-Language
clause	O
,	O
which	O
indicates	O
the	O
table(s )	O
to	O
retrieve	O
data	O
from	B-Language
.	O
</s>
<s>
The	O
FROM	B-Language
clause	O
can	O
include	O
optional	O
JOIN	B-Language
subclauses	O
to	O
specify	O
the	O
rules	O
for	O
joining	O
tables	B-Application
.	O
</s>
<s>
The	O
WHERE	B-Language
clause	O
includes	O
a	O
comparison	O
predicate	O
,	O
which	O
restricts	O
the	O
rows	O
returned	O
by	O
the	O
query	B-Language
.	O
</s>
<s>
The	O
WHERE	B-Language
clause	O
eliminates	O
all	O
rows	O
from	B-Language
the	O
result	B-Application
set	I-Application
where	B-Language
the	O
comparison	O
predicate	O
does	O
not	O
evaluate	O
to	O
True	O
.	O
</s>
<s>
The	O
GROUP	B-Language
BY	I-Language
clause	O
projects	O
rows	O
having	B-Language
common	O
values	O
into	O
a	O
smaller	O
set	O
of	O
rows	O
.	O
</s>
<s>
GROUP	B-Language
BY	I-Language
is	O
often	O
used	O
in	O
conjunction	O
with	O
SQL	B-Language
aggregation	O
functions	O
or	O
to	O
eliminate	O
duplicate	O
rows	O
from	B-Language
a	O
result	B-Application
set	I-Application
.	O
</s>
<s>
The	O
WHERE	B-Language
clause	O
is	O
applied	O
before	O
the	O
GROUP	B-Language
BY	I-Language
clause	O
.	O
</s>
<s>
The	O
HAVING	B-Language
clause	O
includes	O
a	O
predicate	O
used	O
to	O
filter	O
rows	O
resulting	O
from	B-Language
the	O
GROUP	B-Language
BY	I-Language
clause	O
.	O
</s>
<s>
Because	O
it	O
acts	O
on	O
the	O
results	O
of	O
the	O
GROUP	B-Language
BY	I-Language
clause	O
,	O
aggregation	O
functions	O
can	O
be	O
used	O
in	O
the	O
HAVING	B-Language
clause	O
predicate	O
.	O
</s>
<s>
The	O
ORDER	B-Language
BY	I-Language
clause	O
identifies	O
which	O
column[s]	O
to	O
use	O
to	O
sort	O
the	O
resulting	O
data	O
,	O
and	O
in	O
which	O
direction	O
to	O
sort	O
them	O
(	O
ascending	O
or	O
descending	O
)	O
.	O
</s>
<s>
Without	O
an	O
ORDER	B-Language
BY	I-Language
clause	O
,	O
the	O
order	O
of	O
rows	O
returned	O
by	O
an	O
SQL	B-Language
query	I-Language
is	O
undefined	O
.	O
</s>
<s>
The	O
following	O
example	O
of	O
a	O
SELECT	O
query	B-Language
returns	O
a	O
list	O
of	O
expensive	O
books	O
.	O
</s>
<s>
The	O
query	B-Language
retrieves	O
all	O
rows	O
from	B-Language
the	O
Book	O
table	B-Application
in	O
which	O
the	O
price	O
column	O
contains	O
a	O
value	O
greater	O
than	O
100.00	O
.	O
</s>
<s>
The	O
result	O
is	O
sorted	O
in	O
ascending	O
order	B-Language
by	I-Language
title	O
.	O
</s>
<s>
The	O
asterisk	O
( *	O
)	O
in	O
the	O
select	O
list	O
indicates	O
that	O
all	O
columns	B-Application
of	O
the	O
Book	O
table	B-Application
should	O
be	O
included	O
in	O
the	O
result	B-Application
set	I-Application
.	O
</s>
<s>
The	O
example	O
below	O
demonstrates	O
a	O
query	B-Language
of	O
multiple	O
tables	B-Application
,	O
grouping	O
,	O
and	O
aggregation	O
,	O
by	O
returning	O
a	O
list	O
of	O
books	O
and	O
the	O
number	O
of	O
authors	O
associated	O
with	O
each	O
book	O
.	O
</s>
<s>
Under	O
the	O
precondition	O
that	O
isbn	O
is	O
the	O
only	O
common	O
column	O
name	O
of	O
the	O
two	O
tables	B-Application
and	O
that	O
a	O
column	O
named	O
title	O
only	O
exists	O
in	O
the	O
Book	O
table	B-Application
,	O
one	O
could	O
re-write	O
the	O
query	B-Language
above	O
in	O
the	O
following	O
form	O
:	O
</s>
<s>
SQL	B-Language
includes	O
operators	O
and	O
functions	O
for	O
calculating	O
values	O
on	O
stored	O
values	O
.	O
</s>
<s>
SQL	B-Language
allows	O
the	O
use	O
of	O
expressions	O
in	O
the	O
select	O
list	O
to	O
project	O
data	O
,	O
as	B-Language
in	O
the	O
following	O
example	O
,	O
which	O
returns	O
a	O
list	O
of	O
books	O
that	O
cost	O
more	O
than	O
100.00	O
with	O
an	O
additional	O
sales_tax	O
column	O
containing	O
a	O
sales	O
tax	O
figure	O
calculated	O
at	O
6%	O
of	O
the	O
price	O
.	O
</s>
<s>
Queries	B-Language
can	O
be	O
nested	O
so	O
that	O
the	O
results	O
of	O
one	O
query	B-Language
can	O
be	O
used	O
in	O
another	O
query	B-Language
via	O
a	O
relational	O
operator	O
or	O
aggregation	O
function	O
.	O
</s>
<s>
A	O
nested	O
query	B-Language
is	O
also	O
known	O
as	B-Language
a	O
subquery	O
.	O
</s>
<s>
While	O
joins	O
and	O
other	O
table	B-Application
operations	O
provide	O
computationally	O
superior	O
(	O
i.e.	O
</s>
<s>
In	O
the	O
following	O
example	O
,	O
the	O
aggregation	O
function	O
AVG	O
receives	O
as	B-Language
input	O
the	O
result	O
of	O
a	O
subquery	O
:	O
</s>
<s>
A	O
subquery	O
can	O
use	O
values	O
from	B-Language
the	O
outer	O
query	B-Language
,	O
in	O
which	O
case	O
it	O
is	O
known	O
as	B-Language
a	O
correlated	B-Language
subquery	I-Language
.	O
</s>
<s>
Since	O
1999	O
the	O
SQL	B-Language
standard	O
allows	O
named	O
subqueries	O
called	O
common	O
table	B-Application
expressions	O
(	O
named	O
and	O
designed	O
after	O
the	O
IBM	B-Application
DB2	I-Application
version	O
2	O
implementation	O
;	O
Oracle	B-General_Concept
calls	O
these	O
subquery	B-Language
factoring	I-Language
)	O
.	O
</s>
<s>
CTEs	O
can	O
also	O
be	O
recursive	O
by	O
referring	O
to	O
themselves	O
;	O
the	B-Language
resulting	I-Language
mechanism	I-Language
allows	O
tree	O
or	O
graph	O
traversals	O
(	O
when	O
represented	O
as	B-Language
relations	O
)	O
,	O
and	O
more	O
generally	O
fixpoint	O
computations	O
.	O
</s>
<s>
A	O
derived	O
table	B-Application
is	O
the	O
use	O
of	O
referencing	O
an	O
SQL	B-Language
subquery	O
in	O
a	O
FROM	B-Language
clause	O
.	O
</s>
<s>
Essentially	O
,	O
the	O
derived	O
table	B-Application
is	O
a	O
subquery	O
that	O
can	O
be	O
selected	O
from	B-Language
or	O
joined	O
to	O
.	O
</s>
<s>
Derived	O
table	B-Application
functionality	O
allows	O
the	O
user	O
to	O
reference	O
the	O
subquery	O
as	B-Language
a	O
table	B-Application
.	O
</s>
<s>
The	O
derived	O
table	B-Application
also	O
is	O
referred	O
to	O
as	B-Language
an	O
inline	O
view	O
or	O
a	O
select	O
in	O
from	B-Language
list	O
.	O
</s>
<s>
In	O
the	O
following	O
example	O
,	O
the	O
SQL	B-Language
statement	O
involves	O
a	O
join	B-Language
from	B-Language
the	O
initial	O
Books	O
table	B-Application
to	O
the	O
derived	O
table	B-Application
"	O
Sales	O
"	O
.	O
</s>
<s>
This	O
derived	O
table	B-Application
captures	O
associated	O
book	O
sales	O
information	O
using	O
the	O
ISBN	O
to	O
join	B-Language
to	O
the	O
Books	O
table	B-Application
.	O
</s>
<s>
As	B-Language
a	O
result	O
,	O
the	O
derived	O
table	B-Application
provides	O
the	O
result	B-Application
set	I-Application
with	O
additional	O
columns	B-Application
(	O
the	O
number	O
of	O
items	O
sold	O
and	O
the	O
company	O
that	O
sold	O
the	O
books	O
)	O
:	O
</s>
<s>
Given	O
a	O
table	B-Application
T	O
,	O
the	O
query	B-Language
will	O
result	O
in	O
all	O
the	O
elements	O
of	O
all	O
the	O
rows	O
of	O
the	O
table	B-Application
being	O
shown	O
.	O
</s>
<s>
With	O
the	O
same	O
table	B-Application
,	O
the	O
query	B-Language
will	O
result	O
in	O
the	O
elements	O
from	B-Language
the	O
column	O
C1	O
of	O
all	O
the	O
rows	O
of	O
the	O
table	B-Application
being	O
shown	O
.	O
</s>
<s>
This	O
is	O
similar	O
to	O
a	O
projection	B-Algorithm
in	I-Algorithm
relational	I-Algorithm
algebra	I-Algorithm
,	O
except	O
that	O
in	O
the	O
general	O
case	O
,	O
the	O
result	O
may	O
contain	O
duplicate	O
rows	O
.	O
</s>
<s>
This	O
is	O
also	O
known	O
as	B-Language
a	O
Vertical	O
Partition	O
in	O
some	O
database	O
terms	O
,	O
restricting	O
query	B-Language
output	O
to	O
view	O
only	O
specified	O
fields	O
or	O
columns	B-Application
.	O
</s>
<s>
With	O
the	O
same	O
table	B-Application
,	O
the	O
query	B-Language
will	O
result	O
in	O
all	O
the	O
elements	O
of	O
all	O
the	O
rows	O
where	B-Language
the	O
value	O
of	O
column	O
C1	O
is	O
'	O
1	O
 '	O
being	O
shown	O
in	O
relational	B-Algorithm
algebra	I-Algorithm
terms	O
,	O
a	O
selection	B-Algorithm
will	O
be	O
performed	O
,	O
because	O
of	O
the	O
WHERE	B-Language
clause	O
.	O
</s>
<s>
This	O
is	O
also	O
known	O
as	B-Language
a	O
Horizontal	O
Partition	O
,	O
restricting	O
rows	O
output	O
by	O
a	O
query	B-Language
according	O
to	O
specified	O
conditions	O
.	O
</s>
<s>
With	O
more	O
than	O
one	O
table	B-Application
,	O
the	O
result	B-Application
set	I-Application
will	O
be	O
every	O
combination	O
of	O
rows	O
.	O
</s>
<s>
So	O
if	O
two	O
tables	B-Application
are	O
T1	O
and	O
T2	O
,	O
will	O
result	O
in	O
every	O
combination	O
of	O
T1	O
rows	O
with	O
every	O
T2	O
rows	O
.	O
</s>
<s>
Although	O
not	O
in	O
standard	O
,	O
most	O
DBMS	O
allows	O
using	O
a	O
select	O
clause	O
without	O
a	O
table	B-Application
by	O
pretending	O
that	O
an	O
imaginary	O
table	B-Application
with	O
one	O
row	O
is	O
used	O
.	O
</s>
<s>
This	O
is	O
mainly	O
used	O
to	O
perform	O
calculations	O
where	B-Language
a	O
table	B-Application
is	O
not	O
needed	O
.	O
</s>
<s>
The	O
SELECT	O
clause	O
specifies	O
a	O
list	O
of	O
properties	O
(	O
columns	B-Application
)	O
by	O
name	O
,	O
or	O
the	O
wildcard	O
character	O
(“*	O
”	O
)	O
to	O
mean	O
“	O
all	O
properties	O
”	O
.	O
</s>
<s>
This	O
can	O
be	O
used	O
for	O
testing	O
or	O
to	O
prevent	O
consuming	O
excessive	O
resources	O
if	O
the	O
query	B-Language
returns	O
more	O
information	O
than	O
expected	O
.	O
</s>
<s>
ISO	O
SQL:2008	B-Language
introduced	O
the	O
FETCH	O
FIRST	O
clause	O
.	O
</s>
<s>
According	O
to	O
PostgreSQL	B-Application
v.9	O
documentation	O
,	O
an	O
SQL	B-Language
window	I-Language
function	I-Language
"	O
performs	O
a	O
calculation	O
across	O
a	O
set	O
of	O
table	B-Application
rows	O
that	O
are	O
somehow	O
related	O
to	O
the	O
current	O
row	O
"	O
,	O
in	O
a	O
way	O
similar	O
to	O
aggregate	O
functions	O
.	O
</s>
<s>
The	O
name	O
recalls	O
signal	O
processing	O
window	B-Language
functions	I-Language
.	O
</s>
<s>
A	O
window	B-Language
function	I-Language
call	O
always	O
contains	O
an	O
OVER	O
clause	O
.	O
</s>
<s>
ROW_NUMBER( )	O
OVER	O
may	O
be	O
used	O
for	O
a	O
simple	O
table	B-Application
on	O
the	O
returned	O
rows	O
,	O
e.g.	O
</s>
<s>
ROW_NUMBER	O
can	O
be	O
non-deterministic	O
:	O
if	O
sort_key	O
is	O
not	O
unique	O
,	O
each	O
time	O
you	O
run	O
the	O
query	B-Language
it	O
is	O
possible	O
to	O
get	O
different	O
row	O
numbers	O
assigned	O
to	O
any	O
rows	O
where	B-Language
sort_key	O
is	O
the	O
same	O
.	O
</s>
<s>
The	O
RANK( )	O
OVER	O
window	B-Language
function	I-Language
acts	O
like	O
ROW_NUMBER	O
,	O
but	O
may	O
return	O
more	O
or	O
less	O
than	O
n	O
rows	O
in	O
case	O
of	O
tie	O
conditions	O
,	O
e.g.	O
</s>
<s>
Since	O
ISO	O
SQL:2008	B-Language
results	O
limits	O
can	O
be	O
specified	O
as	B-Language
in	O
the	O
following	O
example	O
using	O
the	O
FETCH	O
FIRST	O
clause	O
.	O
</s>
<s>
This	O
clause	O
currently	O
is	O
supported	O
by	O
CA	O
DATACOM/DB	O
11	O
,	O
IBM	B-Application
DB2	I-Application
,	O
SAP	B-Application
SQL	I-Application
Anywhere	I-Application
,	O
PostgreSQL	B-Application
,	O
EffiProz	O
,	O
H2	B-Language
,	O
HSQLDB	B-Application
version	O
2.0	O
,	O
Oracle	B-General_Concept
12c	O
and	O
Mimer	B-Application
SQL	I-Application
.	O
</s>
<s>
Microsoft	B-Application
SQL	I-Application
Server	I-Application
2008	O
and	O
higher	O
,	O
but	O
it	O
is	O
considered	O
part	O
of	O
the	O
ORDER	B-Language
BY	I-Language
clause	O
.	O
</s>
<s>
The	O
ORDER	B-Language
BY	I-Language
,	O
OFFSET	O
,	O
and	O
FETCH	O
FIRST	O
clauses	O
are	O
all	O
required	O
for	O
this	O
usage	O
.	O
</s>
<s>
Some	O
DBMSs	O
offer	O
non-standard	O
syntax	O
either	O
instead	O
of	O
or	O
in	O
addition	O
to	O
SQL	B-Language
standard	O
syntax	O
.	O
</s>
<s>
Below	O
,	O
variants	O
of	O
the	O
simple	O
limit	O
query	B-Language
for	O
different	O
DBMSes	O
are	O
listed	O
:	O
</s>
<s>
WHERE	B-Language
ROWNUM	O
<=	O
10	O
Oracle	B-General_Concept
SELECT	O
FIRST	O
10	O
*	O
from	B-Language
T	O
Ingres	B-Application
SELECT	O
FIRST	O
10	O
*	O
FROM	B-Language
T	O
order	B-Language
by	I-Language
a	O
Informix	B-Application
SELECT	O
SKIP	O
20	O
FIRST	O
10	O
*	O
FROM	B-Language
T	O
order	B-Language
by	I-Language
c	O
,	O
d	O
Informix	B-Application
(	O
row	O
numbers	O
are	O
filtered	O
after	O
order	B-Language
by	I-Language
is	O
evaluated	O
.	O
</s>
<s>
Rows	O
Pagination	O
is	O
an	O
approach	O
used	O
to	O
limit	O
and	O
display	O
only	O
a	O
part	O
of	O
the	O
total	O
data	O
of	O
a	O
query	B-Language
in	O
the	O
database	O
.	O
</s>
<s>
It	O
is	O
very	O
useful	O
,	O
specially	O
in	O
web	O
systems	O
,	O
where	B-Language
there	O
is	O
no	O
dedicated	O
connection	O
between	O
the	O
client	O
and	O
the	O
server	O
,	O
so	O
the	O
client	O
does	O
not	O
have	O
to	O
wait	O
to	O
read	O
and	O
display	O
all	O
the	O
rows	O
of	O
the	O
server	O
.	O
</s>
<s>
SELECT	O
rownum-1	O
as	B-Language
_offset	O
,	O
a	O
.	O
</s>
<s>
Some	O
databases	B-Application
provide	O
specialised	B-Language
syntax	I-Language
for	O
hierarchical	B-General_Concept
data	I-General_Concept
.	O
</s>
<s>
A	O
window	B-Language
function	I-Language
in	O
SQL:2003	B-Language
is	O
an	O
aggregate	O
function	O
applied	O
to	O
a	O
partition	O
of	O
the	O
result	B-Application
set	I-Application
.	O
</s>
<s>
calculates	O
the	O
sum	O
of	O
the	O
populations	O
of	O
all	O
rows	O
having	B-Language
the	O
same	O
city	O
value	O
as	B-Language
the	O
current	O
row	O
.	O
</s>
<s>
The	O
OVER	O
clause	O
can	O
partition	O
and	O
order	O
the	O
result	B-Application
set	I-Application
.	O
</s>
<s>
Ordering	O
is	O
used	O
for	O
order-relative	O
functions	O
such	O
as	B-Language
row_number	O
.	O
</s>
<s>
The	O
processing	O
of	O
a	O
SELECT	O
statement	O
according	O
to	O
ANSI	O
SQL	B-Language
would	O
be	O
the	O
following	O
:	O
</s>
<s>
The	O
implementation	O
of	O
window	B-Language
function	I-Language
features	O
by	O
vendors	O
of	O
relational	O
databases	B-Application
and	O
SQL	B-Language
engines	O
differs	O
wildly	O
.	O
</s>
<s>
Most	O
databases	B-Application
support	O
at	O
least	O
some	O
flavour	O
of	O
window	B-Language
functions	I-Language
.	O
</s>
<s>
Let	O
's	O
take	O
the	O
powerful	O
RANGE	O
clause	O
as	B-Language
an	O
example	O
.	O
</s>
<s>
Only	O
Oracle	B-General_Concept
,	O
DB2	B-Application
,	O
Spark/Hive	O
,	O
and	O
Google	O
Big	O
Query	B-Language
fully	O
implement	O
this	O
feature	O
.	O
</s>
<s>
These	O
are	O
particularly	O
useful	O
in	O
the	O
context	O
of	O
running	O
SQL	B-Language
against	O
a	O
distributed	O
file	O
system	O
(	O
Hadoop	O
,	O
Spark	O
,	O
Google	O
BigQuery	O
)	O
where	B-Language
we	O
have	O
weaker	O
data	O
co-locality	O
guarantees	O
than	O
on	O
a	O
distributed	O
relational	O
database	O
(	O
MPP	O
)	O
.	O
</s>
<s>
Rather	O
than	O
evenly	O
distributing	O
the	O
data	O
across	O
all	O
nodes	O
,	O
SQL	B-Language
engines	O
running	O
queries	B-Language
against	O
a	O
distributed	O
filesystem	O
can	O
achieve	O
data	O
co-locality	O
guarantees	O
by	O
nesting	O
data	O
and	O
thus	O
avoiding	O
potentially	O
expensive	O
joins	O
involving	O
heavy	O
shuffling	O
across	O
the	O
network	O
.	O
</s>
<s>
User-defined	O
aggregate	O
functions	O
that	O
can	O
be	O
used	O
in	O
window	B-Language
functions	I-Language
are	O
another	O
extremely	O
powerful	O
feature	O
.	O
</s>
