Search Shortcut cmd + k | ctrl + k
Search cmd+k ctrl+k
Dark Mode
1.1 (stable)
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" │
└──────────┘