Last array element

Get the last element of an array

Explore this snippet with some demo data here.

Description

You can use ARRAY_SLICE and ARRAY_SIZE to find the last element in an Array in Snowflake:

select 
  array_slice(nums,-1,array_size(nums)) last_element
from 
  (
    select array_construct(1, 2, 3, 4) as nums
  )
LAST_ELEMENT
[4]