Creating new dimensions from existing ones

On this section you'll be presented to the SQL CREATE TABLE AS syntax.


CREATE TABLE AS - Creating new dimensions from existing ones

You can create new dimensions from dimensions that already exist in your SlicingDice's databases using SQL through the workbench, using the /sql endpoint on API or through any tool that supports SQL and can connect to SQL drivers. Check the example below to learn how to use the CREATE TABLE AS statement to execute this operation.

CREATE TABLE [dimension-1] AS (SELECT age FROM (SELECT * FROM [users]));

Notice that the [dimension-1] parameter defines the name of the dimension being created. The (SELECT age FROM (SELECT * FROM [users])) parameter defines the query that will generate the data from the [dimension-1] based on the age column from the [users] dimension.

The Entity IDs for the new dimension being created on the [dimension-1] will be the same from the [users] dimension.

More CREATE TABLE AS use cases

CREATE TABLE [dimension-1] AS (SELECT COUNT(*) from default);
CREATE TABLE [dimension-1] AS (SELECT name, AVG(age) FROM default GROUP BY name);