Using a View in a Query
👤 This section is intended for SQL Users.
Once a view has been created, it's ready to be queried.
On top of selecting all the columns of a view, the user can also join views to each other for more complex analyses, as shown below.
Selecting a Column from a View
Below is a sample view, called web_purchases view.
The following query pulls the user_id column. Notice the square brackets around the view name, web_purchases.
Joining on a View
Square brackets are used only when first referencing the view in the FROM clause, but not when referencing the view in calling columns for the select clause or join condition:
The same notation is used for selecting columns that show up in more than one table or view.
Aliasing a View
Views with longer names are best aliased for brevity and readability. To alias a view or CSV, wrap the alias name in square brackets along with the view name, as shown below.
For users with the cache add-on, joining to a Materialized View or to a CSV Upload requires all tables in the query to be cached and the query to use Redshift-compatible SQL syntax.