All Products
Search
Document Center

Simple Log Service:EXCEPT clause

Last Updated:Jun 16, 2026

The EXCEPT clause combines the result sets of two SELECT statements and returns rows that appear in the first result set but not in the second.

Syntax

SELECT key1... FROM logstore1
EXCEPT
SELECT key2... FROM logstore2
Important
  • Each SELECT statement must have the same number of columns, in the same order, and with matching data types.

  • The EXCEPT clause removes duplicate rows from the final result set.

Parameters

Parameter

Description

key

A field name, column name, or expression.

key1 and key2 can have different values but must have the same data types.

logstore

The name of the Logstore.

Examples

The internal-diagnostic_log Logstore records important logs such as log consumption latency, alerts, and collection data for each Logstore. The internal-operation_log Logstore records detailed operation logs for all resources in a project. The following example uses the EXCEPT clause to find Logstores that generate detailed operation logs but not important diagnostic logs.

  • Query statement

    * |
    SELECT
      logstore
    FROM  internal-operation_log
    EXCEPT
    SELECT
      logstore
    FROM  internal-diagnostic_log
  • The query returns three Logstores: internal-ml-log, test_insert, and oss_metering.