The EXCEPT clause is used to combine the result sets of two SELECT statements and return the difference set of the two result sets. The difference set includes the values that are included in the result set of the first SELECT statement but are not included in the result set of the second SELECT statement. This topic describes the syntax of the EXCEPT clause. This topic also provides examples on how to use the EXCEPT clause.
Syntax
SELECT key1... FROM logstore1
EXCEPT
SELECT key2... FROM logstore2
-
The SELECT statements must return an equal number of columns. The columns must also appear in the same order and have 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. You can specify different values for key1 and key2, but you must specify the same data types for them. |
|
logstore |
The name of the Logstore. |
Examples
A Logstore named internal-diagnostic_log stores important logs, such as consumption latency, alerts, and collection activities for each Logstore. Another Logstore, internal-operation_log, stores detailed operational logs for all resources within a Project. You can use the EXCEPT clause to find which Logstores generate detailed logs but not important ones.
-
Query and analysis statement
* | SELECT logstore FROM internal-operation_log EXCEPT SELECT logstore FROM internal-diagnostic_log -
Query and analysis results
