The syntax for
`SELECT <code> AS attribute, ...`
<code> could be an attribute or an expression.
The most important use case for
* represents all attributes that are not otherwise referenced in the
SELECT statement. It is useful to start almost all of your scripts with
SELECT *, ....
This is the simplest form of
SELECT *, attribute1 AS attribute2;.
The table that results from this statement has the values that were previously in
attribute2. You can rename as many attributes as you want. For example:
SELECT *, attribute1 AS attribute2, attribute3 AS attribute4;
To see an attribute in your unified dataset, you must choose Create attribute on the Schema Mapping page. If you do not do this, then the attribute does not appear in on the Unified Dataset page. You can still reference the attribute in your scripts, but it does not appear in preview or in export.
You can write expressions with
SELECT to manipulate the values in attributes. For example, you could multiply the
Product_Price by a conversion factor to change currencies:
SELECT *, (Product_Price * conversion_factor) AS Product_Price;
You could also choose to have both currencies in your table in separate columns.
(Product_US_Price * conversion_factor) AS Product_EU_Price;
Note: Do not forget to Include
SELECT *. If you do not write
SELECT * at the beginning of these scripts, the table from these transformations will only have the attributes Product_EU_Price, or Product_EU_Price and Product_US_Price, respectively.
Updated 4 months ago