SQL Query
1. Overview
You can use SQL Query to query all the data in the project freely and meet the needs of personalized data retrieval and analysis.
Click "Analysis" and "SQL Query" to see the SQL page, which consists of "Write Box" and "Tabs", and the tabs consist of "Table Structure", "Query History", "Statement Bookmarks" and "Query Results".

2. Applicable Roles and Uses
| Role | Usage |
|---|---|
| Administrator / Analyst | Understand the project's current data assets. |
| Analyst | Freely write SQL queries for all project data to meet individualized fetching and analysis needs that cannot be met in TapDB's inherent analysis model. |
| Business | Replace dynamic parameters in analyst SQL code to meet ongoing fetching and analysis needs. |
3. Table Scope and Notes
3.1 Table Scope
In the TapDB SQL query function, the range of library tables can be queried as follows.
| Table Type | Library Name | Table Name |
|---|---|---|
| Events table | tapdb | view_{{Project ID}}_events |
| Devices table | tapdb | view_{{Project ID}}_devices |
| Users table | tapdb | view_{{Project ID}}_users |
| User clusters table | tapdb | view_{{Project ID}}_cluster |
| Dimension attributes table | tapdb_dim | view_{{Project ID}}_{{Dimension table name}} |
It is recommended to paste the table name into the compose box by using the "Copy Table Name" function in the "Data Table List", as described in section 5.1.2 of this document.
3.2 Notes on using user cluster tables
All user cluster data is stored in the same table view_{{Project ID}}_cluster.

The user IDs under this cluster can be obtained by filtering the cluster name and selecting the phase cluster body field.
The subject of the cluster is "User":
select
user_id
from hive.tapdb.view_{{项目 ID}}_cluster
where cluster_name = ‘{{cluster_name}}’
The subject of the cluster is "Device":
select
device_id
from hive.tapdb.view_{{项目 ID}}_cluster
where cluster_name = ‘{{cluster_name}}’
4. Writing and Executing SQL
The SQL statements are written and executed mainly in the statement writing box.
