Hi! Could we please enable some services and cookies to improve your experience and our website?

SQLize | PHPize | SQLtest

Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code

A A A
Login    Share code      Blog   FAQ
Copy Format Clear
create table records ( user_id int, amount int, date date ); insert into records values (1, 10, '2021-05-01'), (1, 10, '2021-05-02'), (1, 10, '2021-05-03'); select date_trunc('month', to_date('2021-05-03', 'YYYY-MM-DD')); select sum(amount) from records where user_id = 1 and date_trunc('month', date) = date_trunc('month', to_date('2021-05-03', 'YYYY-MM-DD'));

Stuck with a problem? Got Error? Ask AI support!

Copy Clear