Re: extracting a sample of each condition




"jobs" <jobs@xxxxxxxxxx> a écrit dans le message de news: 1185415677.091943.26590@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
| > Have a look at row_number/rank/dense_rank functions.
| > First_value one may also help.
| >
| > Regards
| > Michel Cadot
|
| I don't know if there is a better way to do this, but I have a working
| solution in the form of:
|
| joining the table to the group by in question. If there is a smarter
| way to do this please let me know.
|
| select s.btn btn,s. plan_code,s. fee_type, s.min_type, s.monthly_fee
| from monthly_fee_samples s join
| (select max(t.btn) btn ,t.plan_code,t.fee_type,t.min_type
| from monthly_fee_samples t group by
| t.plan_code,t.fee_type,t.fee_type,t.min_type) x
| on s.btn = x.btn order by s.plan_code
|

Yes, these raninkg function are made for that.
You want the first rows (with rank=1) when you partition
by plan_code, fee_type, fee_type, min_type
and descending order by btn.

Regards
Michel Cadot


.



Relevant Pages

  • Re: Weird SQL
    ... Michel Cadot schrieb: ... Michel, i think, speaking of subquery one should separate 3 different cases: ...
    (comp.databases.oracle.server)
  • Re: Problem with a date in the query !!
    ... | complete error message helps to understand the problem ... - always post your Oracle version and OS name and version ... Regards ... Michel Cadot ...
    (comp.databases.oracle.misc)
  • Re: Problem with a date in the query !!
    ... > | complete error message helps to understand the problem ... > |> Michel Cadot ... Prev by Date: ...
    (comp.databases.oracle.misc)
  • Re: Weird SQL

    (comp.databases.oracle.server)
  • Re: SQL Condition
    ... |> Michel Cadot ...
    (comp.databases.oracle.tools)