Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2013
    Posts
    5

    Unanswered: Need Help with Joining Tables

    Hi guys,

    I am trying to do an inner join on two sub-queries, and I can't figure out what I am doing wrong here. I keep getting syntax errors:


    Code:
    
    SELECT * FROM 
    
    (SELECT SSN
    FROM   [1099_PER]
     INNER
      JOIN ( SELECT SSN, name4, count(*) from [1099_PER] 
    group by SSN, name4
    having count(SSN) > 1 ) As x
        ON x.ssn   = [1099_PER].ssn
       AND x.name4 = [1099_PER].name4 ) as A,
       
    INNER JOIN   
       
    (SELECT SNN
    FROM   original
     INNER
      JOIN ( SELECT SSN, name4, count(*) from original
    group by SSN, name4
    having count(SSN) > 1 ) As x
        ON x.ssn   = original.ssn
       AND x.name4 = original.name4 ) as B
       
       
     ON A.SSN = B.SSN
    Can anyone help?

  2. #2
    Join Date
    Aug 2004
    Location
    Dallas, Texas
    Posts
    831
    Ask the person who wrote the code. Seems this came from another thread?

  3. #3
    Join Date
    Jan 2013
    Posts
    354
    Provided Answers: 1

    we need specs and DDL.

    What is a “name4”? Part of a repeated group? What kind of entity is “Original”? That is an adjective, not a table name!

    >> I am trying to do an inner join on two sub-queries, ..<<

    Why? It looks like you are trying to find duplicated SSNs from a table that had a name in violation of all the ISO Standards. Names in every ISOI Standard I know start with a basic uppercase Latin letter. My guess is:

    SELECT ssn
    FROM Per_1099
    GROUP BY ssn, something_name
    HAVING COUNT(ssn) > 1;

  4. #4
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Erroneous comma after "As A,"
    George
    Home | Blog

Posting Permissions

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