Question: I currently have a class in my HTML file, which is set to hidden in my external CSS file. The class is titled "a."

In my CSS file, I have done this:

```
.a{
    display: none;
}

```

In my external Javscript file, I want to unhide this class. How would I do this? I have currently tried the following:

```
document.getElementsByClassName('a').style.visibility = visible/block;

```

But this hasn't worked.

Thank you.

Answer: 
Postgres supports `DISTINCT ON`, which really facilitates your query. In addition, you can simplify the query because window functions and aggregation functions can be combined on the same level:

```
SELECT DISTINCT ON (co.name) co.*
FROM (SELECT c.name, o.date, SUM(o.volume) as volume,
             LAG(SUM(o.volume)) OVER (PARTITION BY c.name ORDER BY o.date) as prev_volume
      FROM orders o JOIN
           client c 
           USING (client_id)
      GROUP BY c.name, o.date
     ) co
ORDER BY c.name, ABS(volume - prev_volume) DESC

```
Kudos to Gordon Linoff for the majority of this query, however it needed some tweaks, in particular the where clause seen below. 

```
SELECT DISTINCT ON (co.name) 
       co.client_id
     , co.name
     , co.DATE
     , (co.volume - co.prev_volume) change
FROM (
     SELECT 
            c.client_id
          , c.name
          , o.DATE
          , SUM(o.volume) AS volume
          , LAG(SUM(o.volume)) OVER (PARTITION BY c.name 
                                     ORDER BY o.DATE) AS prev_volume
     FROM orders o
     INNER JOIN client c USING (client_id)
     GROUP BY
           c.client_id
          , c.name
          , o.DATE
     ) co
WHERE prev_volume IS NOT NULL
ORDER BY
       co.name
     , ABS(co.volume - co.prev_volume)  DESC

```

Result:

> 
> 
> ```
> 
> client_id | name    | date       | change
> --------: | :------ | :--------- | -----:
>        36 | henry   | 2018-01-30 |    -25
>        41 | james   | 2018-01-17 |     22
>        29 | melinda | 2018-01-29 |    -34
> 
> ```
> 
> 

*db<>fiddle [here](https://dbfiddle.uk/?rdbms=postgres_9.6&fiddle=7f8f5ef99fb879008f8b2ebb9d686dcd)*