VERSION 1
NODE key_verifications_pipe_1411_0
SQL >

    SELECT
        keyId,
        maxSimpleState(time) AS lastUsed
    FROM key_verifications
    GROUP BY keyId

TYPE materialized
DATASOURCE mv_keys_last_used
ENGINE "AggregatingMergeTree"
ENGINE_SORTING_KEY "keyId"

