Creating a Query Using the Query Editor

Use the Query Editor tools and tabs to write an SQL query.

  1. Connect to a database from Interactive SQL.
  2. Select Tools > Edit Query.

    If you have SQL code selected in Interactive SQL, the selected code is automatically imported into the Query Editor

  3. Create your query.
  4. Click OK to write the query to the SQL Statements pane.
  5. Use the tabs that guide you through the components of a SQL query:
    Query Editor Tabs

    Tab

    Description

    Tables tab

    Specifies the tables in your query.

    Joins tab

    Specifies a join strategy for combining the data in the tables. If you include more than one table in your query, you should specify a join strategy for combining the data in the tables. If you do not specify a join strategy for tables you added in the Tables tab, the Query Editor suggests one; if there is a foreign key relationship between the tables, it generates a join condition based on that relationship, or it suggests a cross product. When you open queries, the Query Editor accepts exactly the join strategy that you specified (and an unspecified JOIN is not defaulted to KEY JOIN).

    Columns tab

    Specifies the columns in your result set. If you do not specify columns, all columns appear..

    INTO tab

    Assign results to variables.

    WHERE tab

    Specifies conditions for restricting the rows in your result set.

    GROUP BY tab

    Group rows in the result set.

    HAVING tab

    Restricts the rows in your result set based on group values.

    ORDER BY tab

    Sorts the rows.

  6. Use the following tools:
    Query Editor Tools

    Tool

    Description

    Expression Editor

    Use the Expression Editor to build search conditions or define computed columns.

    Derived Table

    Use this window, which is nearly identical to the main Query Editor, to create derived tables and subqueries.

Related concepts
View Plans Using the Interactive SQL Plan Viewer
Related reference
Tools Menu Window Reference