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

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