Skip to content

Latest commit

 

History

History
19 lines (15 loc) · 561 Bytes

last-array-element.md

File metadata and controls

19 lines (15 loc) · 561 Bytes

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]