Did you try


SELECT    ssn
FROM      
    SELECT    DISTINCT  b.id, b.qnum, b.firstname, b.lastname, b.ssn,
c.phase, c.disbursed_date
    FROM         faLoans a
        INNER JOIN abIdentity b ON a.IdentityID = b.ID
        INNER JOIN Import_Cap_Status c ON b.SSN = c.SSN
        WHERE (c.Branch = 0001) AND (c.phase=1) AND (c.Disbursed_date
between @date2 and  @today)
WHERE (Branch = 0001) AND (phase=2) AND (ssn IN
(#ValueList(addonqueue.ssn)#))

-----Original Message-----
From: Kelly Matthews [mailto:[EMAIL PROTECTED]
Sent: Tuesday, September 28, 2004 3:02 PM
To: SQL
Subject: 2 Queries into one?

Ok I have 2 queries:

1.
CREATE PROCEDURE [dbo].[fa_addonqueue_inout]
@date2 datetime=null,
@today datetime=null

AS
SELECT    DISTINCT  b.id, b.qnum, b.firstname, b.lastname, b.ssn, c.phase,
c.disbursed_date
FROM         faLoans a
INNER JOIN abIdentity b ON a.IdentityID = b.ID
INNER JOIN Import_Cap_Status c ON b.SSN = c.SSN
WHERE (c.Branch = 0001) AND (c.phase=1) AND (c.Disbursed_date between @date2
and  @today)
order by c.disbursed_date DESC
GO

2nd query takes the results from query one and pulls out records that don't
qualify.
SELECT    ssn
FROM      Import_Cap_Status
WHERE (Branch = 0001) AND (phase=2) AND (ssn IN
(#ValueList(addonqueue.ssn)#))

Is there a way to combine these two? any suggestions?  Basically if a person
has 2 records in the db... one with a phase 1 and one with a phase 2 we
don't want them in the results however if they only have a record with phase
1 then we want them to show.
  _____
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

Reply via email to