Hello, I have a fairly simple query im trying to do, but im getting the syntax wrong somewhere. Basically I have this query which would yield the following.:
select distinct sector from sym.symbol order by 1
Energy
Materials
Technology etc....
now what I want to do is get the top 5 symbols from my database for each of these topics and my first attempt was to do this but it is not working, and Im guessing I need a FOR or WHILE loop...
Here is the query that will get what I want if I manually type in each sector.
select t.symbol, sum(vol ) from xxxx.trade t, sym.symbol s where trunc(trade_time) > trunc(sysdate)
and t.symbol=s.symbol and nvl(s.test_symbol,0)<>1
and s.sector = 'Materials'
group by t.symbol order by 2 DESC
Start Free Trial