Results 1 to 2 of 2

Thread: AVG... need to ignore 0

  1. #1
    Chris Williams Guest

    AVG... need to ignore 0


    I need to average a column but ignore records that have a 0. Any thoughts?

  2. #2
    MAK Guest

    AVG... need to ignore 0 (reply)

    create table avgtable (id int, salary int)

    insert into avgtable select 1,100
    insert into avgtable select 2,100
    insert into avgtable select 3,100
    insert into avgtable select 4,100
    insert into avgtable select 5,0
    insert into avgtable select 6,100
    insert into avgtable select 7,100
    insert into avgtable select 8,100
    insert into avgtable select 9,100
    insert into avgtable select 10,0


    select avg(salary) from avgtable where salary<>0



    ------------
    Chris Williams at 4/29/2002 2:22:00 PM


    I need to average a column but ignore records that have a 0. Any thoughts?

Posting Permissions

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