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
-- Table Structure CREATE TABLE t ( v NUMBER ); -- Populate the table with data from the 'V' column in the screenshot INSERT INTO t (v) VALUES (1); INSERT INTO t (v) VALUES (1); INSERT INTO t (v) VALUES (3); INSERT INTO t (v) VALUES (5); INSERT INTO t (v) VALUES (5); INSERT INTO t (v) VALUES (5); INSERT INTO t (v) VALUES (6); -- Commit the changes COMMIT; -- Optional: Verify the data SELECT v FROM t ORDER BY v; SELECT v, SUM(v) OVER (W GROUPS BETWEEN 1 PRECEDING AND 1 FOLLOWING EXCLUDE CURRENT ROW) AS current_row, SUM(v) OVER (W GROUPS BETWEEN 1 PRECEDING AND 1 FOLLOWING EXCLUDE GROUP) AS the_group, SUM(v) OVER (W GROUPS BETWEEN 1 PRECEDING AND 1 FOLLOWING EXCLUDE TIES) AS ties, SUM(v) OVER (W GROUPS BETWEEN 1 PRECEDING AND 1 FOLLOWING EXCLUDE NO OTHERS) AS no_others FROM t WINDOW W AS (ORDER BY v);

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

Copy Clear