~/ 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/b523c26e-a13e-4d07-857d-9303f73d4b32/flashcard utf-8 LF