To list 12 months in a query Oracle SQL -


i need help, please. have query list pdas numbers , need sort in twelve months. query:

select to_char(primeirodia_mes,'mm/yyyy') competencia, 'suporte' tipo,    (select count(tipo)     v_pdas_suporte_se     to_char(primeirodia_mes,'mm/yyyy') = to_char(v_pdas_suporte_se.dt,'mm/yyyy') , tipo in ( 's','e') ) quantidade   (select to_date( '01/'     ||lpad(id,2,0)     ||'/'     ||to_char(sysdate,'yyyy') ,'dd/mm/yyyy') primeirodia_mes        (select level id dual connect level <= 12    ) ) contador  

i need list , example, oct/2014 oct/2015.

i assume looking this:

with t         (select add_months(trunc(sysdate, 'mm'), - level+1) primeirodia_mes      dual connect level <= 13) select      primeirodia_mes competencia,      'suporte' tipo,     count(tipo) v_pdas_suporte_se     right outer join t on primeirodia_mes = trunc(dt, 'mm') group primeirodia_mes; 

Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -