sql >> Database teknologi >  >> RDS >> Oracle

Oracle 10g rekursiv forespørgsel

  select 
    id, 
    customer,
    tickets,
    nvl(
      sum(tickets) over (
        order by id rows between unbounded preceding and 1 preceding
      ), 0) as offset
  from (    
    select
        rownum id,
        customer, 
        tickets
    from tickets
  )

eller endnu mere kortere (uden at introducere id s)

  select 
    customer,
    tickets,
    nvl(
      sum(tickets) over (
        order by rownum rows between unbounded preceding and 1 preceding
      ), 0) as offset
  from tickets



  1. Distinct Records med joins og rækkefølge

  2. MySQL Performance Benchmarking:MySQL 5.7 vs MySQL 8.0

  3. Mysql - Parse fejl (syntaksfejl) i min kode

  4. Webapplikationen [] ser ud til at have startet en tråd med navnet [Oprydningstråd for forladt forbindelse] com.mysql.jdbc.AbandonedConnectionCleanupThread