~/ learn/ postgresql/ cards/ Arrays
1 of 2

Show each book's title, its tags array, and the number of tags (array_length), as tag_count. Order by id.

Show each book's title, its tags array, and the number of tags (array_length), as tag_count. Order by id.

Answer

SELECT title, tags, array_length(tags, 1) AS tag_count FROM books ORDER BY id;

space flip · ← → navigate · esc to exit
NORMAL ~/memra/library/dafc1f24-fb73-42c2-8061-83b84b77a661/flashcard utf-8 LF