Results 1 to 2 of 2
  1. #1
    Join Date
    May 2004
    Posts
    95

    Unanswered: Analytic functions

    Hello everybody,

    I have a doubt regarding analytic functions. I've been working with some functions, but I can't achieve the one wich gives me the pretend result. I know to resolve this without using a function, with a internal select, but I think the analytical function is faster and proper.

    I've got the following data:

    Brand Qt
    A 150
    B 200
    C 50
    D 100

    I wanna he folowing output;

    Brand Overall %
    A 30
    B 40
    C 10
    D 20

    Thanks in advance.

  2. #2
    Join Date
    Jan 2012
    Posts
    84
    Try this query:
    Code:
    with src as (
    select 'A' Brand, 150 Qt from dual union all
    select 'B', 200 from dual union all
    select 'C', 50 from dual union all
    select 'D', 100 from dual 
    )
    
    SELECT brand,
           qt / ( sum( qt ) over () ) * 100  "Overall %"
    from src;

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •