Skip to main content
Commonmark migration
Source Link

#Oracle SQL, 177 bytes

Oracle SQL, 177 bytes

Create a collection type (31 bytes):

CREATE TYPE t IS TABLE OF INT; 

Then use the query (146 bytes):

WITH n(a,b,c)AS(SELECT a,b,t()FROM i UNION ALL SELECT a,b-1,c MULTISET UNION t(COLUMN_VALUE)FROM n,TABLE(n.a)WHERE b>=0)SELECT c FROM n WHERE b=0 

Assuming that the input parameters are in the table i with columns a and b:

CREATE TABLE i (a t,b INT) NESTED TABLE a STORE AS t_a; INSERT INTO i VALUES ( t(1,2,3), 3 ); 

SQL Fiddle

Results:

| C | |-------| | 1,1,1 | | 1,1,2 | | 1,1,3 | | 1,2,1 | | 1,2,2 | | 1,2,3 | | 1,3,1 | | 1,3,2 | | 1,3,3 | | 2,1,1 | | 2,1,2 | | 2,1,3 | | 2,2,1 | | 2,2,2 | | 2,2,3 | | 2,3,1 | | 2,3,2 | | 2,3,3 | | 3,1,1 | | 3,1,2 | | 3,1,3 | | 3,2,1 | | 3,2,2 | | 3,2,3 | | 3,3,1 | | 3,3,2 | | 3,3,3 | 

#Oracle SQL, 177 bytes

Create a collection type (31 bytes):

CREATE TYPE t IS TABLE OF INT; 

Then use the query (146 bytes):

WITH n(a,b,c)AS(SELECT a,b,t()FROM i UNION ALL SELECT a,b-1,c MULTISET UNION t(COLUMN_VALUE)FROM n,TABLE(n.a)WHERE b>=0)SELECT c FROM n WHERE b=0 

Assuming that the input parameters are in the table i with columns a and b:

CREATE TABLE i (a t,b INT) NESTED TABLE a STORE AS t_a; INSERT INTO i VALUES ( t(1,2,3), 3 ); 

SQL Fiddle

Results:

| C | |-------| | 1,1,1 | | 1,1,2 | | 1,1,3 | | 1,2,1 | | 1,2,2 | | 1,2,3 | | 1,3,1 | | 1,3,2 | | 1,3,3 | | 2,1,1 | | 2,1,2 | | 2,1,3 | | 2,2,1 | | 2,2,2 | | 2,2,3 | | 2,3,1 | | 2,3,2 | | 2,3,3 | | 3,1,1 | | 3,1,2 | | 3,1,3 | | 3,2,1 | | 3,2,2 | | 3,2,3 | | 3,3,1 | | 3,3,2 | | 3,3,3 | 

Oracle SQL, 177 bytes

Create a collection type (31 bytes):

CREATE TYPE t IS TABLE OF INT; 

Then use the query (146 bytes):

WITH n(a,b,c)AS(SELECT a,b,t()FROM i UNION ALL SELECT a,b-1,c MULTISET UNION t(COLUMN_VALUE)FROM n,TABLE(n.a)WHERE b>=0)SELECT c FROM n WHERE b=0 

Assuming that the input parameters are in the table i with columns a and b:

CREATE TABLE i (a t,b INT) NESTED TABLE a STORE AS t_a; INSERT INTO i VALUES ( t(1,2,3), 3 ); 

SQL Fiddle

Results:

| C | |-------| | 1,1,1 | | 1,1,2 | | 1,1,3 | | 1,2,1 | | 1,2,2 | | 1,2,3 | | 1,3,1 | | 1,3,2 | | 1,3,3 | | 2,1,1 | | 2,1,2 | | 2,1,3 | | 2,2,1 | | 2,2,2 | | 2,2,3 | | 2,3,1 | | 2,3,2 | | 2,3,3 | | 3,1,1 | | 3,1,2 | | 3,1,3 | | 3,2,1 | | 3,2,2 | | 3,2,3 | | 3,3,1 | | 3,3,2 | | 3,3,3 | 
deleted 40 characters in body
Source Link
MT0
  • 3.5k
  • 1
  • 16
  • 17

#Oracle SQL, 219177 bytes

Create a collection type (31 bytes):

CREATE TYPE t IS TABLE OF INT; 

Then use the query (188146 bytes):

WITH n(a,b,c,v)AS(SELECT a,b,t(),0 FROM i UNION ALL SELECT a,b-1,c MULTISET UNION t(d.COLUMN_VALUE),v*CARDINALITY(a)+d.COLUMN_VALUE FROM n,TABLE(n.a)d WHERE b>=0)SELECT c FROM n WHERE b=0 

Assuming that the input parameters are in the table i with columns a and b:

CREATE TABLE i (a t,b INT) NESTED TABLE a STORE AS t_a; INSERT INTO i VALUES ( t(1,2,3), 3 ); 

SQL FiddleSQL Fiddle

ResultsResults:

| C | |-------| | 1,1,1 | | 1,1,2 | | 1,1,3 | | 1,2,1 | | 1,2,2 | | 1,2,3 | | 1,3,1 | | 1,3,2 | | 1,3,3 | | 2,1,1 | | 2,1,2 | | 2,1,3 | | 2,2,1 | | 2,2,2 | | 2,2,3 | | 2,3,1 | | 2,3,2 | | 2,3,3 | | 3,1,1 | | 3,1,2 | | 3,1,3 | | 3,2,1 | | 3,2,2 | | 3,2,3 | | 3,3,1 | | 3,3,2 | | 3,3,3 | 

#Oracle SQL, 219 bytes

Create a collection type (31 bytes):

CREATE TYPE t IS TABLE OF INT; 

Then use the query (188 bytes):

WITH n(a,b,c,v)AS(SELECT a,b,t(),0 FROM i UNION ALL SELECT a,b-1,c MULTISET UNION t(d.COLUMN_VALUE),v*CARDINALITY(a)+d.COLUMN_VALUE FROM n,TABLE(n.a)d WHERE b>=0)SELECT c FROM n WHERE b=0 

Assuming that the input parameters are in the table i with columns a and b:

CREATE TABLE i (a t,b INT) NESTED TABLE a STORE AS t_a; INSERT INTO i VALUES ( t(1,2,3), 3 ); 

SQL Fiddle

Results:

| C | |-------| | 1,1,1 | | 1,1,2 | | 1,1,3 | | 1,2,1 | | 1,2,2 | | 1,2,3 | | 1,3,1 | | 1,3,2 | | 1,3,3 | | 2,1,1 | | 2,1,2 | | 2,1,3 | | 2,2,1 | | 2,2,2 | | 2,2,3 | | 2,3,1 | | 2,3,2 | | 2,3,3 | | 3,1,1 | | 3,1,2 | | 3,1,3 | | 3,2,1 | | 3,2,2 | | 3,2,3 | | 3,3,1 | | 3,3,2 | | 3,3,3 | 

#Oracle SQL, 177 bytes

Create a collection type (31 bytes):

CREATE TYPE t IS TABLE OF INT; 

Then use the query (146 bytes):

WITH n(a,b,c)AS(SELECT a,b,t()FROM i UNION ALL SELECT a,b-1,c MULTISET UNION t(COLUMN_VALUE)FROM n,TABLE(n.a)WHERE b>=0)SELECT c FROM n WHERE b=0 

Assuming that the input parameters are in the table i with columns a and b:

CREATE TABLE i (a t,b INT) NESTED TABLE a STORE AS t_a; INSERT INTO i VALUES ( t(1,2,3), 3 ); 

SQL Fiddle

Results:

| C | |-------| | 1,1,1 | | 1,1,2 | | 1,1,3 | | 1,2,1 | | 1,2,2 | | 1,2,3 | | 1,3,1 | | 1,3,2 | | 1,3,3 | | 2,1,1 | | 2,1,2 | | 2,1,3 | | 2,2,1 | | 2,2,2 | | 2,2,3 | | 2,3,1 | | 2,3,2 | | 2,3,3 | | 3,1,1 | | 3,1,2 | | 3,1,3 | | 3,2,1 | | 3,2,2 | | 3,2,3 | | 3,3,1 | | 3,3,2 | | 3,3,3 | 
Source Link
MT0
  • 3.5k
  • 1
  • 16
  • 17

#Oracle SQL, 219 bytes

Create a collection type (31 bytes):

CREATE TYPE t IS TABLE OF INT; 

Then use the query (188 bytes):

WITH n(a,b,c,v)AS(SELECT a,b,t(),0 FROM i UNION ALL SELECT a,b-1,c MULTISET UNION t(d.COLUMN_VALUE),v*CARDINALITY(a)+d.COLUMN_VALUE FROM n,TABLE(n.a)d WHERE b>=0)SELECT c FROM n WHERE b=0 

Assuming that the input parameters are in the table i with columns a and b:

CREATE TABLE i (a t,b INT) NESTED TABLE a STORE AS t_a; INSERT INTO i VALUES ( t(1,2,3), 3 ); 

SQL Fiddle

Results:

| C | |-------| | 1,1,1 | | 1,1,2 | | 1,1,3 | | 1,2,1 | | 1,2,2 | | 1,2,3 | | 1,3,1 | | 1,3,2 | | 1,3,3 | | 2,1,1 | | 2,1,2 | | 2,1,3 | | 2,2,1 | | 2,2,2 | | 2,2,3 | | 2,3,1 | | 2,3,2 | | 2,3,3 | | 3,1,1 | | 3,1,2 | | 3,1,3 | | 3,2,1 | | 3,2,2 | | 3,2,3 | | 3,3,1 | | 3,3,2 | | 3,3,3 |