Sam and Carp,
I hope you don't mind my jumping into the fray, but there are several issues with your query that we should look at. First, Sam, are you sure that your CASE statements are working as you wish? When I posted the CASE code for you yesterday, it was counting date entries only once.
Your current code could count the same row up to 4 times -- if a "als_created_date" contains yesterday's date, it will tally for each of your four conditions since it is between 25, 35, 55, and greater days ago and today.
Second, you have given a column alias of "b" to each of your four CASE columns.
Third, you cannot refer to a column alias in your WHERE clause of the same SELECT. In other words, you cannot say:
Code:
...WHERE ( a is not null or b IS NOT NULL
OR c IS NOT NULL
OR d IS NOT NULL)
...since b is an alias and a,c, and d should give you "undefined" errors.
Frankly, I cannot see how the code you posted gave the results you posted. Are you sure you are not using some "smoke and mirrors" on us?
Let us know,
![[santa] [santa] [santa]](/data/assets/smilies/santa.gif)
Mufasa
(aka Dave of Sandy, Utah, USA)
@ 17:06 (21Dec04) UTC (aka "GMT" and "Zulu"),
@ 10:06 (21Dec04) Mountain Time