Ivan
Ivan

Reputation: 480

calculating empirical distribution of dataset in oracle using model clause

I can find empirical distribution that way

    select command_type, duration, round(percentage, 2)
    from (select distinct command_type,duration_sec,
                        percent_rank() over(partition by command_type order by duration) percentage
          from command_durations
          order by 1, 2)

The question is how to do the same using oracle model clause. I have started with this

select command_type,duration,dur_count from command_durations
model UNIQUE SINGLE REFERENCE
partition by (command_type)
dimension by ( duration)
measures(0 dur_count)
rules(
dur_count[duration]=count(1)[cv(duration)]
)
order by command_type,duration

But now I need to make records distinct, in order to be able to proceed with finding empirical distribution.

How to do the records distinct in the model clause?

Upvotes: 2

Views: 165

Answers (1)

Phillip
Phillip

Reputation: 457

If you want to take that query and use 'distinct' on it, one method might be to wrap that in a From Subquery statement, and then do a distinct. For instance:

Select Distinct command_type, duration, dur_count
From (
    [Your Code]
)

Let me know if that works.

Upvotes: 1

Related Questions