Solved

Why am I getting different results with theses queries?

Posted on 2012-03-20
3
213 Views
Last Modified: 2012-03-20
I am trying to clean up a query that I use everyday, but cannot understand why these queries would result in different data. Both queries are reporting daily unique new approved applications.Anyone see what I may be missing?
declare @fiscalyear as int
declare @fiscalmonth as int
set @fiscalyear = '2012'
set @fiscalmonth = '201203'

Select DATE,
count(distinct case when loan_type = 'pdl' and app_type = 'std' and cust_type = 'new' and processing_status <> 'denied'
	and (reason_for_denial not in('auto withdrawl during esign !','Auto Withdrawn During LatitudePayment Return !','Alternate Product ILP Accepted'
	,'Fraud','DNQ - Direct Deposit','DNQ - No Longer Employed','DNQ - Income','DNQ - Card Account','DNQ - Work Number',
	'DNQ - Home/Cell Number','Store Collections','Auto Withdrawn During ACH Return !') or (reason_for_denial is NULL)) 
	then bo_code else 0 end) as 'PDL New Approved'
from USOnlineReporting.dbo.BO_IN_APP_QUEUE bia
inner join USOnlineReporting.dbo.Business_Dates_All bda on bda.Date = dateadd(dd,0,datediff(dd,0,app_date))
where FiscalYear = @fiscalyear
and FiscalMonth = @fiscalmonth
group by date
order by date

Open in new window

SELECT dateadd(dd,0,datediff(dd,0,APP_DATE)),
COUNT(distinct((bo_in_app_queue.BO_CODE))) as New_Approved
FROM USOnlineReporting.dbo.BO_IN_APP_QUEUE
WHERE (APP_TYPE='STD') 
AND (LOAN_TYPE='PDL')
AND (PROCESSING_STATUS<>'DENIED')
AND (CUST_TYPE='NEW')
AND (REASON_FOR_DENIAL not in('auto withdrawl during esign !','Auto Withdrawn During LatitudePayment Return !','Alternate Product ILP Accepted'
,'Fraud','DNQ - Direct Deposit','DNQ - No Longer Employed','DNQ - Income','DNQ - Card Account','DNQ - Work Number',
'DNQ - Home/Cell Number','Store Collections','Auto Withdrawn During ACH Return !') OR (REASON_FOR_DENIAL is NULL))
and dateadd(dd,0,datediff(dd,0,APP_DATE)) >= '2/26/2012'
group by dateadd(dd,0,datediff(dd,0,APP_DATE))
order by dateadd(dd,0,datediff(dd,0,APP_DATE))

Open in new window

0
Comment
Question by:dplowman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 55

Accepted Solution

by:
Huseyin KAHRAMAN earned 500 total points
ID: 37743957
what data you get from both queries?

if you change this line

then bo_code else 0 end) as 'PDL New Approved'
>>>
then bo_code else null end) as 'PDL New Approved'

do you get same result?
0
 

Author Comment

by:dplowman
ID: 37744047
Thanks, that was it. It actually solved the majority of my problem. Why would the 0 throw the data off compared to using null?
0
 
LVL 55

Expert Comment

by:Huseyin KAHRAMAN
ID: 37744357
null is ignored in count...
0 is counted as a separate item...
0

Featured Post

Comparison of Amazon Drive, Google Drive, OneDrive

What is Best for Backup: Amazon Drive, Google Drive or MS OneDrive? In this free whitepaper we look at their performance, pricing, and platform availability to help you decide which cloud drive is right for your situation. Download and read the results of our testing for free!

Question has a verified solution.

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

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

724 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