Case Statement

  • I want to know how to write a case statement that does an average of two tables.

    Here is an example:

    "CASE When online > 0 then online else student end"

    where do I put the avg in that statement

  • I'm assuming you mean the avg for either online or student. If that's correct, it would be something like:

    case

    when avg(online) > 0 then avg(online)

    else avg(student)

    end

    That might have performance problems, because it has to average the "online" before it can figure out which to display, but it should work.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • hnguye21 (6/3/2008)


    I want to know how to write a case statement that does an average of two tables.

    Here is an example:

    "CASE When online > 0 then online else student end"

    where do I put the avg in that statement

    Are "online" and "student" tables ?


    * Noel

  • hi,

    please clarify whether online and student is just a text or table.?

    regards,

    vijay

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply