Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Where vs Case

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-06-17 : 19:11:31
JPaulo writes "I have a column in the SELECT:

Case
When (Table1.Field1='+' and Table1.Field2='+' and Sum(Field3) Is Null ) then (Table1.field4-Table2.field5)
When (Table1.Field1='+' and Table1.Field2='+' and Sum(Field3) Is Not Null ) then (Table1.field4-Table2.field5)
...
End as DIFERENCA

I want the result of the query to be filter like:

Where DIFERENCA<>0

or....

Where
(Case
When (Table1.Field1='+' and Table1.Field2='+' and Sum(Field3) Is Null ) then (Table1.field4-Table2.field5)
When (Table1.Field1='+' and Table1.Field2='+' and Sum(Field3) Is Not Null ) then (Table1.field4-Table2.field5)
...
End )<>0

But i keep having this error:
"An aggregate may not appear in the WHERE clause unless it is in a subquery contained in a HAVING clause or a select list, and the column being aggregated is an outer reference."

What can i do to overcame this problem?

Tks!"
   

- Advertisement -