Writing a SQL Code on Editor

SQL Editor is a versatile feature of Report V2 which lets you write Simple to Complex SQL Code and create various kinds of reports on top of the SQL code's output data table.

It really comes in handy when you have a raw data table that you need to explore on the go and create reports on top of that.

Features of SQL Editor

SQL Editor Window: This is the main section where you can write and run Simple/Complex SQL Queries using the raw data warehouse tables to get the desired data.

*Here you can write only the "SELECT" SQL statements not any DML statements like INSERT, UPDATE, etc. For eg: "Select * from employees". The idea is to let you explore tables that are present in your data warehouse.

Output Window: This is where the output of your SQL code will populate after clicking on the Run button. You can use it to go through the data and cross-check it. The Errors (if any) while executing your code would also appear here.

Schema Browser: This allows to search any table along with its schema that is present in the configured Data Warehouse.

You can easily type the required table name in the Search bar and it will give you the list of all the columns and their data types present in the mentioned table. You can double-click on the column name/table name to add it to the code.

Variables Panel: This allows you to add any new Local variables and see the existing list of Local and Global variables. Variables are useful to provide values to your code during the run-time to get the required data.

Visualization Panel: This allows you to switch to the reporting part using which you can create various kinds of reports on top of the output data of your SQL Code.

Build a Report using SQL Editor

Let's say you have an Order_details raw table which you need to modify first using some SQL query and then use the final table to perform some analysis like "Product Category wise Total Orders".

  • Click on β€œ+ Create Report” and choose SQL Editor.

  • Give a name to the Report and now you will land on the Report V2 -SQL Editor UI.

  • Now in the SQL Editor tab write the SQL query which you want to use to modify the Order_details table and click the Run button.

For eg: If you want to analyze only the North region order's data and also want to combine order_id and location_id columns to create a new column tracking_id then you can write the following Code

Select a.*, concat(a.order_id,'-',a.location_id) as tracking id

from orders_details

where a.region ='North';

  • You will now have a final table as the Output of the above SQL query.

  • Now go to the Visualization Tab below the Schema Browser tab and choose the Pie Chart option.

  • In the Build panel go to the Chart Setting section and select Measure column Count of Order_id in the Values section and select Product Category column in the Labels section.

  • Click on the Visualize Button and your Pie Chart will be ready showcasing "Product Category wise Total Orders" for only the North region as you required.

Last updated