Advertisement

10.05.2007 at 09:16AM PDT, ID: 22875175
[x]
Attachment Details

Oracle Loop Query

Asked by Extreme66 in Oracle SCM, Oracle 10.x, PL / SQL

Tags: oracle, loop, query

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
[+][-]10.05.2007 at 09:19AM PDT, ID: 20023105

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.05.2007 at 09:20AM PDT, ID: 20023112

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.05.2007 at 09:51AM PDT, ID: 20023304

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10.06.2007 at 10:40AM PDT, ID: 20028062

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.07.2007 at 07:28PM PDT, ID: 20031968

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Oracle SCM, Oracle 10.x, PL / SQL
Tags: oracle, loop, query
Sign Up Now!
Solution Provided By: NicksonKoh
Participating Experts: 2
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628