Question: I have the following SUB QUERY as part of a SELECT statement. Which is supposed to take one calculated time, away from another calculated time.

However Postgres doesn't like having the Window function within the FROM clause.

```
(SELECT count(*) AS work_hours
FROM   generate_series (TIMESTAMP 'epoch' + MAX(wog.endtime) OVER(PARTITION     BY woas.workorderid ORDER BY wog.endtime DESC)/1000 * INTERVAL '1 second'
                  , TIMESTAMP 'epoch' + nth_value(wog.endtime,2) OVER(PARTITION BY woas.workorderid ORDER BY wog.endtime DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)/1000 * INTERVAL '1 second' - interval '1h'
                  , interval '1h') h
WHERE  EXTRACT(ISODOW FROM h) < 6
AND    h::time >= '08:00'
AND    h::time <= '18:00') AS "Max minus Second Max",

```

Postgres returns the following error:

```
ERROR: cannot use window function in function expression in FROM

```

How can I reformat the above statement, so that it parses without error?

Update:

I dont think the structure of the query is the issue. If I put timestamp string in place of the functions it works fine.

```
 (SELECT count(*) AS work_hours
 FROM generate_series (timestamp '2018-01-06 13:30'
                  , timestamp '2018-01-08 21:29' - interval '1h'
                  , interval '1h') h
 WHERE  EXTRACT(ISODOW FROM h) < 6
 AND    h::time >= '08:00'
 AND    h::time <= '18:00') "Time Difference" from workorder wo

```

Answer: 
On the div that you are trying to disable right click events, you can just add this:

```
oncontextmenu="return false;"

```

Example:

```
<div oncontextmenu="return false;">This div won't have the right click menu</div>

```
You have to add an event on the specific div ( you can get the div by id document.getElementById ) and add an event listener for contextmenu. 
Example:

```
    document.getElementById("divId").addEventListener("contextmenu ", function(){
       console.log("Right Click");
       return false;
    });

```