⌘+k ctrl+k
1.1.3 (stable)
Search Shortcut cmd + k | ctrl + k
Indexing

DuckDB uses 1-based indexing except for JSON objects, which use 0-based indexing.

Examples

The index origin is 1 for strings, lists, etc.

SELECT list[1] AS element
FROM (SELECT ['first', 'second', 'third'] AS list);
┌─────────┐
│ element │
│ varchar │
├─────────┤
│ first   │
└─────────┘

The index origin is 0 for JSON objects.

SELECT json[1] AS element
FROM (SELECT '["first", "second", "third"]'::JSON AS json);
┌──────────┐
│ element  │
│   json   │
├──────────┤
│ "second" │
└──────────┘