~/ learn/ postgresql/ cards/ Window Functions
1 of 8

Show each book’s title, price, and the overall average price (same on every row) as avg_all.

Show each book’s title, price, and the overall average price (same on every row) as avg_all.

Answer

SELECT title, price, AVG(price) OVER () AS avg_all FROM books;

space flip · ← → navigate · esc to exit
NORMAL ~/memra/library/7b7cfc95-2de4-4a3f-a169-d9d0c457a60a/flashcard utf-8 LF