tanj1035
asked on
SQL, Null value is eliminated by an aggregate or other SET operation.
Hi Experts,
The error message below showed up after I ran the query . I have checked the sub-query and there was no null value in there. I do not know if the warning message will affect the result or not? Thank you.
Warning: Null value is eliminated by an aggregate or other SET operation.
(2 row(s) affected)
The error message below showed up after I ran the query . I have checked the sub-query and there was no null value in there. I do not know if the warning message will affect the result or not? Thank you.
Warning: Null value is eliminated by an aggregate or other SET operation.
(2 row(s) affected)
SELECT companyname
, SUM(CASE WHEN LoanAmountFinanced <='2500.00' THEN 1 ELSE 0 END) AS NUMBEROFLOANSLESS2500
, SUM(CASE WHEN LoanAmountFinanced <='6000.00' AND LoanAmountFinanced >'2500.00'THEN 1 ELSE 0 END) AS NUMBEROFLOANS2500TO6000
, SUM(CASE WHEN LoanAmountFinanced <='10000.00' AND LoanAmountFinanced >'6000.00'THEN 1 ELSE 0 END) AS NUMBEROFLOANS6000TO10000
, SUM(CASE WHEN LoanAmountFinanced <='20000.00' AND LoanAmountFinanced >'10000.00'THEN 1 ELSE 0 END) AS NUMBEROFLOANS10000TO20000
, SUM(CASE WHEN LoanAmountFinanced >='20000.00' THEN 1 ELSE 0 END) AS NUMBEROFLOANSOVER20000
, SUM(CASE WHEN LoanAmountFinanced <='2500.00' THEN LoanAmountFinanced ELSE 0 END) AS LOANSLESS2500
, SUM(CASE WHEN LoanAmountFinanced <='6000.00' AND LoanAmountFinanced >'2500.00'THEN LoanAmountFinanced ELSE 0 END) AS LOANS2500TO6000
, SUM(CASE WHEN LoanAmountFinanced <='10000.00' AND LoanAmountFinanced >'6000.00'THEN LoanAmountFinanced ELSE 0 END) AS LOANS6000TO10000
, SUM(CASE WHEN LoanAmountFinanced <='20000.00' AND LoanAmountFinanced >'10000.00'THEN LoanAmountFinanced ELSE 0 END) AS LOANS10000TO20000
, SUM(CASE WHEN LoanAmountFinanced >='20000.00' THEN LoanAmountFinanced ELSE 0 END) AS LOANSOVER20000
, MAX(CASE WHEN LoanAmountFinanced <='2500.00' THEN TILAAPR END ) AS HIGHAPRFOR0TO2500
, MIN(CASE WHEN LoanAmountFinanced <='2500.00' THEN TILAAPR END ) AS LOWAPRFOR0TO2500
, MAX(CASE WHEN LoanAmountFinanced >'2500.00' THEN TILAAPR END ) AS HIGHAPRFOROVER2500
, MIN(CASE WHEN LoanAmountFinanced >'2500.00' THEN TILAAPR END ) AS LOWAPRFOROVER2500
INTO #LOANSETA
FROM (
SELECT S.companyname
, L.LoanID
, L.LoanAmountFinanced
, FN.TILAAPR
FROM tblLoans L inner join
#GROUPBYSTORES S ON S.STOREID= L.LoanStoreID
CROSS APPLY GetTILAInfo (LoanID) as FN
WHERE L.LoanDate >= '20150101' and L.LoanDate < '20160101'
) A
GROUP BY companyname
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
PLEASE READ EVERYTHING ABOUT ANSI WARNINGS BEFORE CHANGING THAT SETTING!!!!!!!!
It is there and set to ON by default for a very good reason.
It is there and set to ON by default for a very good reason.
Where is saying that ON is the default value? By the MSDN article I posted above:
" The default value in the model database for SET ANSI_WARNINGS is OFF. If not specified, the setting of ANSI_WARNINGS applies. If SET ANSI_WARNINGS is OFF, SQL Server uses the value of the is_ansi_warnings_on column in the sys.databases catalog view."
Anyway, the OP can always set it back to ON after the SELECT statement.
SET ANSI_WARNINGS OFF
SELECT ...
(...)
SET ANSI_WARNINGS ON
" The default value in the model database for SET ANSI_WARNINGS is OFF. If not specified, the setting of ANSI_WARNINGS applies. If SET ANSI_WARNINGS is OFF, SQL Server uses the value of the is_ansi_warnings_on column in the sys.databases catalog view."
Anyway, the OP can always set it back to ON after the SELECT statement.
SET ANSI_WARNINGS OFF
SELECT ...
(...)
SET ANSI_WARNINGS ON
True, Vitor. And good example of how to do this for the one query and then turn it back on. I just see too many people think, "Oh, I should just always turn that off so it will never get in my way." But not think or realize the other effects of making that change.
ASKER
Thank Vitor and Chris' sharing.
I understand that can be annoying especially if it appears in your application.
You can turn it off by executing the following command before the query:
SET ANSI_WARNINGS OFF