have 2 queries wondering if I can accomplish this in 1.

Query 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

Query 2:
  SELECT    ssn
  FROM      Import_Cap_Status
  WHERE (Branch = 0001) AND (phase=2) AND (ssn IN (#ValueList(addonqueue.ssn)#))

Basically w/ query 2 I am taking the results of query 1 and going back through them and pulling any records that have phase 2 as well (that means the person would have 2 records a phase 1 & phase 2), these are then going to be eliminated from what we display on the page.  Any suggestions on combining this query?
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

Reply via email to