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…
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)- A88% (42)
- B4% (2)
- C2% (1)
- D6% (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
Community Discussion
No community discussion yet for this question.