sql >> Database >  >> RDS >> Oracle

Oracle SQL - DENSE_RANK

Zoals ik begrepen heb, is dit wat je nodig hebt:

select client_ID, status_id, from_date, to_date, 
       sum(start_of_group) over (order by client_ID, from_date) + 1 rank
  from (SELECT c.client_ID, c.status_id, c.from_date, c.to_date,
               case when lag(c.client_ID, 1, c.client_ID) over (order by c.client_ID, c.from_date) = c.client_ID 
                     and lag(c.status_id, 1, c.status_id) over (order by c.client_ID, c.from_date) = c.status_id
                    then 0 else 1 end start_of_group
          FROM client c)
 order by client_ID, from_date

SQLFiddle



  1. Hoe converteer je CLOB naar BLOB in Oracle?

  2. Retour bestaat niet record in de tabel

  3. Hoe PostgreSQL 9.1 op OSX Lion te installeren

  4. Best practices:onderhouds- en verbeteringstaken voor Oracle Cloud