SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular

SQLize.online is a free online SQL environment for quickly running, experimenting with and sharing code. You can run your SQL code on top of the most popular RDBMS including MySQL, MariaDB, SQLite, PostgreSQL, Oracle and Microsoft SQL Server.

Copy Format Clear
create table t( date date, type text, price int ); insert into t values ("2020-01-01", "laptop", "210"), ("2020-01-01", "pc", "100"), ("2020-01-02", "laptop", "150"), ("2020-01-02", "pc", "200"), ("2020-01-03", "laptop", "150"), ("2021-01-01", "pc", "110"), ("2021-01-01", "laptop", "220"), ("2021-01-02", "pc", "210"), ("2021-01-02", "laptop", "200"), ("2021-01-03", "pc", "26"); select date, abs(sum-first_month_value)/2 from (select sum(price) as sum, count(date) as count, date, first_value(sum(price)) over() as first_month_value from t group by date order by date) as t;

Stuck with a problem? Got Error? Ask ChatGPT!

Copy Clear