SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
SELECT yearweek(payment_date) payment_week, sum(amount) week_total, lag(sum(amount), 1) over(order by yearweek(payment_date)) prev_wk_tot, lead(sum(amount), 1) over(order by yearweek(payment_date)) next_wk_tot FROM payment GROUP BY yearweek(payment_date) ORDER BY 1

Stuck with a problem? Got Error? Ask ChatGPT!

Copy Clear