SELECT *
FROM (SELECT c1, c2, c3, c4, c5, c6
FROM (SELECT 'a' c1, 'b' c2, 'c' c3, 'd' c4, 'e' c5, 'f' c6
FROM DUAL)
GROUP BY CUBE (c1, c2, c3, c4, c5, c6));
C1 C2 C3 C4 C5 C6
f
e
e f
d
d f
d e
d e f
c
c f
c e
c e f
c d
c d f
c d e
c d e f
b
b f
b e
b e f
b d
b d f
b d e
b d e f
b c
b c f
b c e
b c e f
b c d
b c d f
b c d e
b c d e f
a
a f
a e
a e f
a d
a d f
a d e
a d e f
a c
a c f
a c e
a c e f
a c d
a c d f
a c d e
a c d e f
a b
a b f
a b e
a b e f
a b d
a b d f
a b d e
a b d e f
a b c
a b c f
a b c e
a b c e f
a b c d
a b c d f
a b c d e
a b c d e f
and it illustrates the beauty (and complexity) of CUBE.
A very simple SQL example that shows off what is possible from something very simple.
No comments:
Post a Comment