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
histogram to percentiles
Correlated subquery in SELECT clause, and rewritten for Netezza
SQL Moving Rating Practice by Han Wang 20200720
filme
PostreSQL: Today's Date/Time
testo
Movie Rating SQL Analysis Conducted by Miranda Zhao
Replace key of json
complicated-conditional-sql-query-to-match-attributes-for-marketing-campaigns/43219741#43219741
How i can get the difference of closest two date in two table join in postgresql