I’m trying to execute the following query:
Code:
SELECT dbo_master.Number, dbo_master.Original, dbo_master.Paid, dbo_master.Score, dbo_MiscExtra.TheData as ChargeOffCode
FROM dbo_master LEFT JOIN dbo_MiscExtra
ON dbo_master.Number = dbo_miscextra.number
WHERE dbo_Master.customer = 'ADS1S' AND dbo_miscextra.Title = 'Charge-off Reason Code: '
It executes however my problem is as follows.
I want ALL of the records from dbo_master to show up in my query result where customer = 'ADS1S' regardless of whether or not there is a matching record in dbo_miscextra.
This query
Code:
SELECT count(*)
FROM dbo_master
WHERE dbo_Master.customer = 'ADS1S'
Results in 245,617 records while this query
Code:
SELECT count(*)
FROM dbo_master LEFT JOIN dbo_MiscExtra
ON dbo_master.Number = dbo_miscextra.number
WHERE dbo_Master.customer = 'ADS1S' AND dbo_miscextra.Title = 'Charge-off Reason Code: '
Results in 94,154 records
I want my final result to include 245,617 records and 94,154 of them include a result for the ChargeOffCode. I'm sure it has to do with adding the additional [AND] statement in the WHERE clause but I can't think of another way to execute the query. Maybe I have to first create a tempory table and do the join on that, but I'm thinking there is an easier way.
Any help would be appreciated.