DISQUS

Eddie Awad’s Blog: Cool SQL Analytic Function: RATIO_TO_REPORT

  • Karl · 2 years ago

    Hi Eddie;
    used it today the first time!
    Karl

  • Tshepo · 1 year ago
    Using the query below, I need to calculate ratio of paper to electronic claims. Pls help




    select practice_fk as 'Prac_No1',
    p.doc_short_descr as 'Prac_Name1',
    DS.dsp_ind,
    accreditation,
    accred_level,
    SUM(isnull(convert(numeric,(1)),0)) as 'Total_Claims',
    SUM(CASE WHEN convert(numeric,trade_fk) 0 THEN 1 ELSE 0 END) as 'EDI',
    SUM(CASE WHEN convert(numeric,trade_fk) = 0 THEN 1 ELSE 0 END) as 'Paper'

    from ( select c.claim_fk,c.trade_fk,c.practice_fk,c.rcvd_date
    from tf_claim C with (nolock)
    where benefit_amt >= 0.05
    AND practice_type IN (14,15,50,51)
    AND convert(datetime,convert(varchar,claim_dt),112) BETWEEN '1 MAY 2008' AND '31 AUG 2008'
    group by c.claim_fk,c.trade_fk,c.practice_fk,c.rcvd_date
    ) CLAIM LEFT JOIN td_practice P with (nolock) ON (practice_pk = practice_fk)
    LEFT JOIN pcdw2.dw_staging.dbo.tsd_dsp ds ON (ds.practice_pk = claim.practice_fk)
    LEFT JOIN dbo.td_negotiation2 n on (n.negotiation_pk = ds.neg_num)

    Where DS.dsp_ind = 'DSP'

    group by practice_fk,
    p.doc_short_descr,ds.dsp_ind,accreditation,
    accred_level
  • Sergio · 1 year ago
    Hi Eddie,

    I googling for ratio_to_report and came across your post. I noticed it links to an old blog post of mine. orablogs.com kicked the bucket a long time ago. FWIW, I revived this post on my new blog:

    http://blogs.oracle.com/sergio/2008/10/quick_an...

    Sergio
  • Eddie Awad · 1 year ago
    Thanks Sergio, I have updated my post with your new URL.