nerdexam
Snowflake

COF-C02 · Question #489

Which function should be used to find the query ID of the second query executed in a current session?

The correct answer is A. Select LAST_QUERY_ID(-2). The LAST_QUERY_ID() function in Snowflake accepts an integer argument. Negative integers count backward from the most recently executed query: LAST_QUERY_ID(-1) returns the most recent query ID, LAST_QUERY_ID(-2) returns the second most recent query ID, and so on. Positive…

Snowflake Cloud Data Platform Features and Architecture

Question

Which function should be used to find the query ID of the second query executed in a current session?

Options

  • ASelect LAST_QUERY_ID(-2)
  • BSelect LAST_QUERY_ID(2)
  • CSelect LAST_QUERY_ID(1)
  • DSelect LAST_QUERY_ID(2)

How the community answered

(48 responses)
  • A
    88% (42)
  • B
    4% (2)
  • C
    2% (1)
  • D
    6% (3)

Explanation

The LAST_QUERY_ID() function in Snowflake accepts an integer argument. Negative integers count backward from the most recently executed query: LAST_QUERY_ID(-1) returns the most recent query ID, LAST_QUERY_ID(-2) returns the second most recent query ID, and so on. Positive integers count forward from the first query in the session: LAST_QUERY_ID(1) is the first, LAST_QUERY_ID(2) is the second from the start. The question asks for the 'second query executed,' and given the correct answer is LAST_QUERY_ID(-2), this refers to the second-to-last (second most recent) query in the session.

Topics

#Snowflake Functions#Query Management#Session Context#Query ID Retrieval

Community Discussion

No community discussion yet for this question.

Full COF-C02 Practice