You need to enable JavaScript to run this app.
Torch Log Service

Torch Log Service

Copy page
Download PDF
SQL syntax
DISTINCT clause
Copy page
Download PDF
DISTINCT clause
The DISTINCT clause should be used in the SELECT clause to remove duplicate values from the specified fields. That is, when a field contains multiple duplicate values, you can use the DISTINCT clause to remove duplicates and extract only unique values. This document introduces the syntax format and examples of the DISTINCT clause.​
Grammar format​
The syntax of the DISTINCT clause is as follows.​
​
DISTINCT Key|(Key)​
​
​
Parameter​
Notice​
Key​
Log field name or asterisk (*). When set to an asterisk (*), deduplication is performed on all columns in the log.​
​
Syntax example​
Example 1​
  • Scenarios​
  • Query the unique values of the TopicID field.​
  • Query and analysis statement​
  • ​
    * | SELECT DISTINCT TopicID WHERE TopicID !='' ​
    ​
  • or​
  • ​
    * | SELECT DISTINCT(TopicID) WHERE TopicID !=''​
    ​
  • Query and analysis results​
  • ​​​
Example 2​
  • Scenario:​
  • Count the number of Topics​
  • Query and analysis statement​
  • ​
    * | SELECT COUNT(DISTINCT TopicID) WHERE TopicID !='' ​
    ​
    或​
    ​
    * | SELECT COUNT(DISTINCT(TopicID)) WHERE TopicID !=''​
    ​
  • Query and analysis results​
  • ​​​
​
Last updated: 2026.07.22 18:38:21