#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Posts
    1
    Rep Power
    0

    Lightbulb report fraction in sql


    Hi,
    How can I report the fraction of certain item in SQL?
    For example:
    select count(*)/sum(count (*))
    from...
    group by...
    But it is not allowed of multifuntion in oracle like above. Is there any other way to do this?
    Thank you very much for your kind help!
  2. #2
  3. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,118
    Rep Power
    4274
    which item?


    something like this:
    Code:
    select sum(case when columnX='foo' then 1 else 0 end)
         / count(*) as fraction
      from yourtable
    rudy

IMN logo majestic logo threadwatch logo seochat tools logo