can I use partition with the following

Hi, I wanted to know if I can use or partition the row to the GET the necessary results below. If Yes can someone help me with it.
If there is another way to get results as you please let me know.

I use Oracle 10.2.0.4.0 version

Create a table script:
CREATE TABLE DMM.QUES
(
  CASENAME        VARCHAR2(100 BYTE),
  CASENUMBER      VARCHAR2(20 BYTE),
  COVERAGE        VARCHAR2(10 BYTE),
  DIVISIONNUMBER  VARCHAR2(6 BYTE),
  CLASSNUMBER     number,
  TIER            VARCHAR2(2 BYTE),
  MONTHLYRATE     NUMBER
  )
Insert manuscripts of the declaration:
insert into QUES (CASENAME,CASENUMBER,  COVERAGE,  DIVISIONNUMBER,  CLASSNUMBER,  TIER,MONTHLYRATE)
values ('ABC','123J','health', '456J','987',null,.25)
insert into QUES (CASENAME,CASENUMBER,  COVERAGE,  DIVISIONNUMBER,  CLASSNUMBER,  TIER,MONTHLYRATE)
values ('ABC','123J','health', '456J','123',null,.25)
insert into QUES (CASENAME,CASENUMBER,  COVERAGE,  DIVISIONNUMBER,  CLASSNUMBER,  TIER,MONTHLYRATE)
values ('ABC','123J','health', '456J','453',null,.25)
insert into QUES (CASENAME,CASENUMBER,  COVERAGE,  DIVISIONNUMBER,  CLASSNUMBER,  TIER,MONTHLYRATE)
values ('ABC','123J','dental', '456J','453','ee',.29)
insert into QUES (CASENAME,CASENUMBER,  COVERAGE,  DIVISIONNUMBER,  CLASSNUMBER,  TIER,MONTHLYRATE)
values ('ABC','123J','dental', '456J','453','es',.23)
insert into QUES (CASENAME,CASENUMBER,  COVERAGE,  DIVISIONNUMBER,  CLASSNUMBER,  TIER,MONTHLYRATE)
values ('ABC','123J','dental', '456J','453','ec',.44)
insert into QUES (CASENAME,CASENUMBER,  COVERAGE,  DIVISIONNUMBER,  CLASSNUMBER,  TIER,MONTHLYRATE)
values ('ABC','123J','dental', '456J','453','fa',.33)
insert into QUES (CASENAME,CASENUMBER,  COVERAGE,  DIVISIONNUMBER,  CLASSNUMBER,  TIER,MONTHLYRATE)
values ('ABC','123J','dental', '456J','123','ee',.45)
insert into QUES (CASENAME,CASENUMBER,  COVERAGE,  DIVISIONNUMBER,  CLASSNUMBER,  TIER,MONTHLYRATE)
values ('ABC','123J','dental', '456J','123','es',.45)
insert into QUES (CASENAME,CASENUMBER,  COVERAGE,  DIVISIONNUMBER,  CLASSNUMBER,  TIER,MONTHLYRATE)
values ('ABC','123J','dental', '456J','123','ec',.46)
insert into QUES (CASENAME,CASENUMBER,  COVERAGE,  DIVISIONNUMBER,  CLASSNUMBER,  TIER,MONTHLYRATE)
values ('ABC','123J','dental', '456J','123','fa',.49)
Select * of question:
ABC     123J     health     456J     987          0.25
ABC     123J     health     456J     453          0.25
ABC     123J     health     456J     123          0.25
ABC     123J     dental     456J     453     ee     0.29
ABC     123J     dental     456J     453     es     0.23
ABC     123J     dental     456J     453     ec     0.44
ABC     123J     dental     456J     453     fa     0.33
ABC     123J     dental     456J     123     ee     0.45
ABC     123J     dental     456J     123     es     0.45
ABC     123J     dental     456J     123     ec     0.46
ABC     123J     dental     456J     123     fa     0.49
I would get the following result
ABC     123J     health     456J     123          0.25
ABC     123J     dental     456J     123     ee     0.45
ABC     123J     dental     456J     123     es     0.45
ABC     123J     dental     456J     123     ec     0.46
ABC     123J     dental     456J     123     fa     0.49
I would like the code to take the minimum of classnumber for each combination of divisonnumber/cover and give me all the records in this classnumber.


Thanks in advance.

Hello

This is an example of a Query of Top - N , and Yes, the analytic functions are a good way to do it:

WITH     got_r_num     AS
(
     SELECT     ques.*
     ,     RANK () OVER ( PARTITION BY  coverage
                           ,          divisionnumber
                      ORDER BY          classnumber
                    ) AS r_num
     FROM    ques
)
SELECT  casename, casenumber, coverage, divisionnumber, classnumber, tier, monthlyrate
FROM     got_r_num
WHERE     r_num     = 1
;

Thanks for posting the CREATE TABLE and INSERT, it is very useful!

"PARTITION OF ' is a term often used with analytic functions. "PARTTIION" means also at least two other things in Oracle, so people you better understand if you say "analytic functions", rather than "partition by.

For more info about the RANK function, see this thread:
Re: A "working group"double"SQL query

Tags: Database

Similar Questions

Maybe you are looking for

  • Standing recalls in the middle of the night and sleep hours does not connect

    I get reminders throughout the night to get up and walk for a minute. Put my silent mode shows is not an option that I need to receive calls from work. In addition, my hours of sleep are not connect properly.

  • Driver Intel HD 4000

    Is there a way I can install the drivers of 4000 HD directly from the Intel site? I mean, the newest driver HP for the Intel HD 4000 is among more than a year and it is really important (having the latest drivers) For now, I'll have the FPS issues wi

  • WAG200G wireless problems

    Hi guys,. I recently bought the WAG200G and set up and it was working fine. After a month, the problem that has arisen is as follows: I try to search for wireless (WLAN) network but can not find. The PC that is connected via the cable works well, but

  • change default audio codec

    Hello. Just a simple question about codec audio default on SX80 (TC7.3) H.323 call. Is it somehow possible to change the type of codec to alaw ulaw G.711? Thank you. Marcel

  • How to send a Notification to several email id Workflow Oracle

    HelloI have a requirement in R12.1.3 where we send same email Notification multiple identification of in Oracle Workflow. Get us identification of email running for each transaction.Current workflow process is notification is sent to an email Id whic