Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT "PLAN_ITEM_ID",
- SUM("SECONDS_PER_DAY" * (
- SELECT count(1)
- from generate_series("START_TIME", "END_TIME" - interval '1 day', '1 day') as days
- where extract(isodow from days) < 6
- ) - (SELECT count(1)
- FROM "AO_013613_HD_SCHEME_DAY" JOIN (
- SELECT generate_series("START_TIME", "END_TIME" , '1 day') as days
- FROM "AO_2D3BEA_PLAN_ALLOCATION"
- WHERE "PLAN_ITEM_ID" = 374447
- )U
- ON "AO_013613_HD_SCHEME_DAY"."DATE" = U.days))
- FROM "AO_2D3BEA_PLAN_ALLOCATION"
- WHERE "PLAN_ITEM_ID" = 374344
- group by "PLAN_ITEM_ID";
Advertisement
Add Comment
Please, Sign In to add comment