So you have the table setup similar to this:
create table scores(
Player varchar(20) not null,
score1 int not null,
score2 int not null
);
And your data similar to this:
insert into scores(player, score1, score2) values('player 1', 0, 0);
insert into scores(player, score1, score2) values('player 1', 10, 20);
insert into scores(player, score1, score2) values('player 1', 20, 30);
And when you run the query with criteria similar to this:
SELECT Player,
Avg(Case When Score1> 0 then Score1 end) AS AverageScore1,
Avg(Case When Score2> 0 then Score2 end) AS AverageScore2
FROM scores
where Score1<10 and Score2<10
GROUP BY Player
You get output like this:
Player AverageScore1 AverageScore2
--------- --------------- -----------------
Player1 NULL NULL
But what you want is:
Player AverageScore1 AverageScore2
--------- --------------- -----------------
Is that right?
If so, adding a "HAVING" clause will filter out the records with NULLS:
SELECT Player,
Avg(Case When Score1> 0 then Score1 end) AS AverageScore1,
Avg(Case When Score2> 0 then Score2 end) AS AverageScore2
FROM scores
where Score1<10 and Score2<10
GROUP BY Player
having Avg(Case When Score1> 0 then Score1 end) is not null and
Avg(Case When Score2> 0 then Score2 end) is not null
HAVING Avg(Case When Score1> 0 then Score1 end) IS NOT NULL?ISNULLanswer will work