Results 1 to 4 of 4

Thread: sql select

  1. #1
    Join Date
    Apr 2003
    Posts
    176

    Unanswered: sql select

    SELECT email_Address,COUNT(*) COUNT
    INTO #temp12
    FROM #temp2
    GROUP BY email_Address
    Having COUNT(*)>=2
    ORDER BY COUNT(*) DESC

    SELECT * FROM emp WHERE email_address IN(SELECT email_address FROM #temp12)

    How can i combine above two sql statements into one.

    Thanks.

  2. #2
    Join Date
    Jul 2003
    Location
    San Antonio, TX
    Posts
    3,662
    SELECT emp.* FROM emp
    inner join (
    SELECT email_Address,COUNT(*) COUNT
    FROM #temp2
    GROUP BY email_Address
    Having COUNT(*)>=2
    ) x on emp.email_address x.email_address

  3. #3
    Join Date
    Mar 2004
    Posts
    8
    Alternatively:

    SELECT * FROM emp WHERE email_address IN (
    SELECT email_Address
    FROM #temp2
    GROUP BY email_Address
    HAVING COUNT(*) >= 2
    )

  4. #4
    Join Date
    Apr 2003
    Posts
    176
    thanks,It worked fine.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •