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
Solved

Why am I getting different results with theses queries?

Posted on 2012-03-20
3
206 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
  • 2
3 Comments
 
LVL 51

Accepted Solution

by:
HainKurt 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 51

Expert Comment

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

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Suggested Solutions

I have written a PowerShell script to "walk" the security structure of each SQL instance to find:         Each Login (Windows or SQL)             * Its Server Roles             * Every database to which the login is mapped             * The associated "Database User" for this …
SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

860 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