ElJayWilson
Programmer
I have a table that has some records that are the same other than one of the fields is NULL in one record and populatated in another record (same AwardNumber, different ActivityNumbers). The following view will not pull records due to there being instances of NULL values for Mnemonic in the CHAOS_Awards table. For example:
AwardNumber ActivityNumber Mnemonic
1000 1 NULL
1000 2 ITMER
The query used currently will not pull records because of that one record for AwardNumber 1000 that has a NULL value in Mnemonic.
I am having a hard time modifying the query so that I will get records unless there are no records for the JOINed AwardNumber that are NOT NULL.
Here is the current SQL:
Please help...
Thanks!
AwardNumber ActivityNumber Mnemonic
1000 1 NULL
1000 2 ITMER
The query used currently will not pull records because of that one record for AwardNumber 1000 that has a NULL value in Mnemonic.
I am having a hard time modifying the query so that I will get records unless there are no records for the JOINed AwardNumber that are NOT NULL.
Here is the current SQL:
Code:
SELECT TOP (100) PERCENT ca.Mnemonic, sv.award_fk, pp.visit_fk, pp.AccountNumber, SUM(pp.quantity * p.UnitPrice) AS totalVisitCost,
pc.amount AS pendingChangeTotal, sv.subject_fk, ISNULL(st.FirstName, '') + ' ' + ISNULL(st.MiddleInitial, '') + ' ' + ISNULL(st.LastName, '')
AS participantName, sv.is_reconciled
FROM dbo.Procedures_Performed AS pp INNER JOIN
dbo.ProceduresPermitted_tbl AS p ON p.ProcedureID = pp.procedure_fk INNER JOIN
dbo.Scheduled_Visits AS sv ON sv.id = pp.visit_fk INNER JOIN
dbo.Subjects_tbl AS st ON sv.subject_fk = st.SubjectID LEFT OUTER JOIN
CHAOS.dbo.CHAOS_Awards AS ca ON ca.AwardNumber = sv.award_fk AND ca.Mnemonic IS NOT NULL LEFT OUTER JOIN
dbo.Reconciliation_Pending_Changes AS pc ON pc.visit_fk = sv.id AND pc.completeDate IS NULL
WHERE (sv.award_fk <> 1865) AND (ca.[Finalized Mnemonic] = '0')
GROUP BY ca.Mnemonic, sv.award_fk, pp.visit_fk, pp.AccountNumber, pc.amount, sv.subject_fk, ISNULL(st.FirstName, '') + ' ' + ISNULL(st.MiddleInitial, '')
+ ' ' + ISNULL(st.LastName, ''), sv.is_reconciled
Please help...
Thanks!