Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
postgresql: working days
--PostgreSQL 9.5 --'\\' is a delimiter ---create table create table orderT ( id integer PRIMARY KEY, country_code varchar(2), created_date date, closed_date date ); ---populate table INSERT INTO orderT VALUES (1, 'US', '2017-03-03'::date, '2017-03-03'::date + interval '1 day' * 21); INSERT INTO orderT VALUES (2, 'CA', '2017-03-03'::date, '2017-03-03'::date + interval '1 day' * 35); SELECT h.id, count(*) as wkday FROM ( SELECT t.id, max(created_date) as createddt, max(closed_date) as closeddt FROM orderT t group by t.id ) h , generate_series(h.createddt, h.closeddt, interval '1 day') i where extract(dow from i::date) between 1 and 5 group by h.id;
run
|
edit
|
history
|
help
0
PC02-DB-UTEC
PostgreSQL Sandbox: Legitimate Resale
SQL social network practice by Han Wang 20200720 - 2
simple add function on sql
Final test
LeetCode 178
test jsonb_set of PostgreSQL
IF IN POSTGRESQL
Cross Tab With Totals
Final 2