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
podd version
PostreSQL: CASE
LeetCode 178
Studco
mandelbrot set
Assignment 1(SET A)
testo
test
Movie Rating SQL Analysis Project
Assignment 1(SET A)