~/ learn/ postgresql/ cards/ Windows: aggregates that keep the rows
1 of 2

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/7bc9938f-4c41-4a71-8b9f-bd20fbe13c43/flashcard utf-8 LF