Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Warning: Null value is eliminated by an aggregate or other SET operation.???

Posted on 2006-07-07
4
Medium Priority
?
1,658 Views
Last Modified: 2008-01-09
Hi all

I have this query below when i run it gives a message:
Warning: Null value is eliminated by an aggregate or other SET operation.

How do I solve that warning?

Please kindly assist, thanks

SELECT
R1.JobNumber,
R1.JobName,
R1.ProjectManagerNumber,
CASE WHEN R1.LastTimeReg = '1900.01.01' THEN 'N/A' ELSE R1.LastTimeReg END AS LastTimeReg,
CASE WHEN R1.LastExpenseReg = '1900.01.01' THEN 'N/A' ELSE R1.LastExpenseReg END AS LastExpenseReg,
CASE WHEN R1.LastPOReg = '1900.01.01' THEN 'N/A' ELSE R1.LastPOReg END  AS LastPOReg

FROM
(SELECT
JH.JobNumber,
JH.JobName,
JH.ProjectManagerNumber,
ISNULL(MAX(TSL.PeriodStart), '1900.01.01') AS LastTimeReg,
ISNULL(MAX(ESL.DateOfEntry), '1900.01.01') AS LastExpenseReg,
ISNULL(MAX(RH.CreatedDate), '1900.01.01') AS LastPOReg

FROM
JobHeader JH LEFT OUTER JOIN TimeSheetLine TSL ON JH.JobNumber = TSL.JobNumber
LEFT OUTER JOIN ExpenseSheetLine ESL ON JH.JobNumber = ESL.JobNumber
LEFT OUTER JOIN RequisitionHeader RH ON JH.JobNumber = RH.JobNumber
WHERE
(JH.IsBlocked = 0 AND JH.BlockedForInvoicing = 0 AND JH.Closed = 0 AND JH.Template = 0)
GROUP BY
JH.JobNumber,
JH.JobName,
JH.ProjectManagerNumber
) AS R1

WHERE
R1.ProjectManagerNumber  = '300020'
AND (R1.LastTimeReg != '1900.01.01' OR R1.LastExpenseReg != '1900.01.01' OR R1.LastPOReg != '1900.01.01')
AND ((DateDiff(Day, R1.LastTimeReg, GetDate()) >= 28) AND (DateDiff(Day,R1.LastExpenseReg, GetDate()) >= 28) AND (DateDiff(Day, R1.LastPOReg, GetDate()) >= 28))
0
Comment
Question by:minichicken
4 Comments
 
LVL 25

Accepted Solution

by:
Mr_Peerapol earned 2000 total points
ID: 17058329
I guess that some records might have NULL values in TSL.PeriodStart, ESL.DateOfEntry, RH.CreatedDate.

You can do like this:

ISNULL(MAX(ISNULL(TSL.PeriodStart, '1900.01.01')), '1900.01.01') AS LastTimeReg,
ISNULL(MAX(ISNULL(ESL.DateOfEntry, '1900.01.01')), '1900.01.01') AS LastExpenseReg,
ISNULL(MAX(ISNULL(RH.CreatedDate, '1900.01.01')), '1900.01.01') AS LastPOReg
0
 
LVL 23

Expert Comment

by:Racim BOUDJAKDJI
ID: 17058434
Get rid of NULL values on your database.  Simplest and long lasting effect solution.
0
 
LVL 12

Author Comment

by:minichicken
ID: 17058452
Perfect Mr_Peerapol, you the best!!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.

926 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question