I have this output:
It's data of stock symbol, closing values and the year of the closing of the stock. I make the output from this query:
select symbol, close, extract(year from time) as tahun
from (select * from (select * from tabel1 where close > (select avg(close) from tabel1))
as result where open < close) as result group by symbol, close, tahun
Now, I want to find the 2016 closing values that has higher value than year 2017 (2016 > 2017). I'm stuck, please anyone can help?
[EDIT]
This is the original data:
How I define closing value for a year:
- I extract all the closing values that has higher values than averag closing values. Here's the query:
select * from tabel1 where close > (select avg(close) from tabel1)
- Then, from query above I extract the closing values that has higher values than the opening (open < close). Here's the query:
select * from (select * from tabel1 where close > (select avg(close) from tabel1)) as result where open < close
- From the second output, I tried to group the data by symbol and find the 2016 closing values that has higher values than 2017 closing values. But I'm stuck with this query, seems that I don't know how to compare between the years that stored in one column:
select symbol, close, extract(year from time) as tahun
from (select * from (select * from tabel1 where close > (select avg(close) from tabel1)) as result where open < close) as result group by symbol, close, tahun


