Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Union Joins

Posted on 2012-04-04
11
Medium Priority
?
245 Views
Last Modified: 2012-04-17
I have three unions [1011], [1011], [1112].

With the unions you need to have the same numhber of rows in each select, which is fine.

The additional select in each union is      
,[Primary Diagnosis Code],LEFT([Primary Diagnosis Code],5) AS PRIMARY_DIAGNOSIS_ICD10,ICD_PRIM_DIAG.ICD104NM AS PRIMARY_DIAGNOSIS_DESC

But my question is I only want to do the joins on the last union. But this causes a problem because Msg 4104, Level 16, State 1, Line 119
The multi-part identifier "ICD_PRIM_DIAG.ICD104NM" could not be bound.
Msg 4104, Level 16, State 1, Line 279
The multi-part identifier "ICD_PRIM_DIAG.ICD104NM" could not be bound.

Which means the join need to be in each union.



SELECT

     
      [Primary Diagnosis Code]
      ,LEFT([Primary Diagnosis Code],5) AS PRIMARY_DIAGNOSIS_ICD10
        ,ICD_PRIM_DIAG.ICD104NM AS PRIMARY_DIAGNOSIS_DESC
     
      ,[Secondary Diagnosis Code 1]
      ,[Secondary Diagnosis Code 2]
      ,[Secondary Diagnosis Code 3]
      ,[Secondary Diagnosis Code 4]


           
FROM  [0910]


      UNION ALL

     
SELECT  

     
      [Primary Diagnosis Code]
      ,LEFT([Primary Diagnosis Code],5) AS PRIMARY_DIAGNOSIS_ICD10
        ,ICD_PRIM_DIAG.ICD104NM AS PRIMARY_DIAGNOSIS_DESC
     
      ,[Secondary Diagnosis Code 1]
      ,[Secondary Diagnosis Code 2]
      ,[Secondary Diagnosis Code 3]
      ,[Secondary Diagnosis Code 4]

     
FROM [1011]

      UNION ALL

SELECT

      [Primary Diagnosis Code]
      ,LEFT([Primary Diagnosis Code],5) AS PRIMARY_DIAGNOSIS_ICD10
        ,ICD_PRIM_DIAG.ICD104NM AS PRIMARY_DIAGNOSIS_DESC
     
     
      ,[Secondary Diagnosis Code 1]
      ,[Secondary Diagnosis Code 2]
      ,[Secondary Diagnosis Code 3]
      ,[Secondary Diagnosis Code 4]
 
 
     
FROM      [1112]

                  LEFT OUTER JOIN
            [LookUp].[dbo].[tbl_ICD10] AS ICD_PRIM_DIAG
                  ON ICD_PRIM_DIAG.ICD104CD = LEFT([Primary Diagnosis Code],4)

                  LEFT OUTER JOIN
            [LookUp].[dbo].[tbl_ICD10] AS ICD_SEC1_DIAG
                  ON ICD_SEC1_DIAG.ICD104CD = [Secondary Diagnosis Code 1]

                  LEFT OUTER JOIN
            [LookUp].[dbo].[tbl_ICD10] AS ICD_SEC2_DIAG
                  ON ICD_SEC2_DIAG.ICD104CD = [Secondary Diagnosis Code 2]

                  LEFT OUTER JOIN
            [LookUp].[dbo].[tbl_ICD10] AS ICD_SEC3_DIAG
                  ON ICD_SEC3_DIAG.ICD104CD = [Secondary Diagnosis Code 3]

                  LEFT OUTER JOIN
            [LookUp].[dbo].[tbl_ICD10] AS ICD_SEC4_DIAG
                  ON ICD_SEC4_DIAG.ICD104CD = [Secondary Diagnosis Code 4]


GO
0
Comment
Question by:aneilg
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
11 Comments
 
LVL 6

Expert Comment

by:ingriT
ID: 37805012
Try using the UNION keyword instead of the UNION ALL keyword.
0
 
LVL 15

Accepted Solution

by:
gplana earned 1300 total points
ID: 37805035
ingriT: UNION eliminates duplicates and UNION ALL don't. So I don't think the solution is to change UNION ALL by UNIONs.

aneilg: All SELECTs should have the same number of columns, and the same datatype on every column, but every select can have a different number of rows, no problem on this.

I'm not understanding the problem: it looks like ICD_PRIM_DIAG.ICD104NM field is on one of the join tables, so if you want this field on a select you need to join to this table. If you don't want this column on a select, just replace it by a value that matches the datatype of this field. For example, if this field is a text based field, you can do something like this:

SELECT

     
      [Primary Diagnosis Code]
      ,LEFT([Primary Diagnosis Code],5) AS PRIMARY_DIAGNOSIS_ICD10
        ,ICD_PRIM_DIAG.ICD104NM AS PRIMARY_DIAGNOSIS_DESC
     
      ,[Secondary Diagnosis Code 1]
      ,[Secondary Diagnosis Code 2]
      ,[Secondary Diagnosis Code 3]
      ,[Secondary Diagnosis Code 4]


           
FROM  [0910]


      UNION ALL

     
SELECT  

     
      [Primary Diagnosis Code]
      ,LEFT([Primary Diagnosis Code],5) AS PRIMARY_DIAGNOSIS_ICD10
        ,'' AS PRIMARY_DIAGNOSIS_DESC
     
      ,[Secondary Diagnosis Code 1]
      ,[Secondary Diagnosis Code 2]
      ,[Secondary Diagnosis Code 3]
      ,[Secondary Diagnosis Code 4]

     
FROM [1011]

      UNION ALL

SELECT

      [Primary Diagnosis Code]
      ,LEFT([Primary Diagnosis Code],5) AS PRIMARY_DIAGNOSIS_ICD10
        ,'' AS PRIMARY_DIAGNOSIS_DESC
     
     
      ,[Secondary Diagnosis Code 1]
      ,[Secondary Diagnosis Code 2]
      ,[Secondary Diagnosis Code 3]
      ,[Secondary Diagnosis Code 4]
 
 
     
FROM      [1112]

                  LEFT OUTER JOIN
            [LookUp].[dbo].[tbl_ICD10] AS ICD_PRIM_DIAG
                  ON ICD_PRIM_DIAG.ICD104CD = LEFT([Primary Diagnosis Code],4)

                  LEFT OUTER JOIN
            [LookUp].[dbo].[tbl_ICD10] AS ICD_SEC1_DIAG
                  ON ICD_SEC1_DIAG.ICD104CD = [Secondary Diagnosis Code 1]

                  LEFT OUTER JOIN
            [LookUp].[dbo].[tbl_ICD10] AS ICD_SEC2_DIAG
                  ON ICD_SEC2_DIAG.ICD104CD = [Secondary Diagnosis Code 2]

                  LEFT OUTER JOIN
            [LookUp].[dbo].[tbl_ICD10] AS ICD_SEC3_DIAG
                  ON ICD_SEC3_DIAG.ICD104CD = [Secondary Diagnosis Code 3]

                  LEFT OUTER JOIN
            [LookUp].[dbo].[tbl_ICD10] AS ICD_SEC4_DIAG
                  ON ICD_SEC4_DIAG.ICD104CD = [Secondary Diagnosis Code 4]


GO

Open in new window


Hope it helps
0
 

Author Comment

by:aneilg
ID: 37805264
this is an example of the select working.

my question is, is it possible not to have the joins in each union, only having the join on [1112]. but the problem is

Msg 4104, Level 16, State 1, Line 119
The multi-part identifier "ICD_PRIM_DIAG.ICD104NM" could not be bound.
ect.

the query as it stands need the joins in each union. is it possible to only have the join on
the last query

SELECT

      ,[Primary Diagnosis Code]
      ,LEFT([Primary Diagnosis Code],5) AS PRIMARY_DIAGNOSIS_ICD10
        ,ICD_PRIM_DIAG.ICD104NM AS PRIMARY_DIAGNOSIS_DESC
     
      ,[Secondary Diagnosis Code 1]
      ,LEFT([Secondary Diagnosis Code 1],5) AS [1ST_SEC_DIAGNOSIS_ICD10]
        ,ICD_SEC1_DIAG.ICD104NM AS SEC_DIAG1ST_DESC
     
      ,[Secondary Diagnosis Code 2]
      ,LEFT([Secondary Diagnosis Code 2],5) AS [2ND_SEC_DIAGNOSIS_ICD10]
        ,ICD_SEC2_DIAG.ICD104NM AS SEC_DIAG2ND_DESC
     
      ,[Secondary Diagnosis Code 3]
      ,left([Secondary Diagnosis Code 3],5) AS [3RD_SEC_DIAGNOSIS_ICD10]
        ,ICD_SEC3_DIAG.ICD104NM AS SEC_DIAG3RD_DESC
     
      ,[Secondary Diagnosis Code 4]
      ,left([Secondary Diagnosis Code 4],5) AS [4TH_SEC_DIAGNOSIS_ICD10]
        ,ICD_SEC4_DIAG.ICD104NM AS SEC_DIAG4TH_DESC
     

            
FROM  [0910]

            --      LEFT OUTER JOIN
            --[LookUp].[dbo].[tbl_ICD10] AS ICD_PRIM_DIAG
            --      ON ICD_PRIM_DIAG.ICD104CD = LEFT([Primary Diagnosis Code],4)

            --      LEFT OUTER JOIN
            --[LookUp].[dbo].[tbl_ICD10] AS ICD_SEC1_DIAG
            --      ON ICD_SEC1_DIAG.ICD104CD = [Secondary Diagnosis Code 1]

            --      LEFT OUTER JOIN
            --[LookUp].[dbo].[tbl_ICD10] AS ICD_SEC2_DIAG
            --      ON ICD_SEC2_DIAG.ICD104CD = [Secondary Diagnosis Code 2]

            --      LEFT OUTER JOIN
            --[LookUp].[dbo].[tbl_ICD10] AS ICD_SEC3_DIAG
            --      ON ICD_SEC3_DIAG.ICD104CD = [Secondary Diagnosis Code 3]

            --      LEFT OUTER JOIN
            --[LookUp].[dbo].[tbl_ICD10] AS ICD_SEC4_DIAG
            --      ON ICD_SEC4_DIAG.ICD104CD = [Secondary Diagnosis Code 4]

      UNION

      
SELECT  

     
      ,[Primary Diagnosis Code]
      ,LEFT([Primary Diagnosis Code],5) AS PRIMARY_DIAGNOSIS_ICD10
        ,ICD_PRIM_DIAG.ICD104NM AS PRIMARY_DIAGNOSIS_DESC
     
      ,[Secondary Diagnosis Code 1]
      ,LEFT([Secondary Diagnosis Code 1],5) AS [1ST_SEC_DIAGNOSIS_ICD10]
        ,ICD_SEC1_DIAG.ICD104NM AS SEC_DIAG1ST_DESC
     
      ,[Secondary Diagnosis Code 2]
      ,LEFT([Secondary Diagnosis Code 2],5) AS [2ND_SEC_DIAGNOSIS_ICD10]
        ,ICD_SEC2_DIAG.ICD104NM AS SEC_DIAG2ND_DESC
     
      ,[Secondary Diagnosis Code 3]
      ,left([Secondary Diagnosis Code 3],5) AS [3RD_SEC_DIAGNOSIS_ICD10]
        ,ICD_SEC3_DIAG.ICD104NM AS SEC_DIAG3RD_DESC
     
      ,[Secondary Diagnosis Code 4]
      ,left([Secondary Diagnosis Code 4],5) AS [4TH_SEC_DIAGNOSIS_ICD10]
        ,ICD_SEC4_DIAG.ICD104NM AS SEC_DIAG4TH_DESC
     

      
      
FROM [1011]

            --      LEFT OUTER JOIN
            --[LookUp].[dbo].[tbl_ICD10] AS ICD_PRIM_DIAG
            --      ON ICD_PRIM_DIAG.ICD104CD = LEFT([Primary Diagnosis Code],4)

            --      LEFT OUTER JOIN
            --[LookUp].[dbo].[tbl_ICD10] AS ICD_SEC1_DIAG
            --      ON ICD_SEC1_DIAG.ICD104CD = [Secondary Diagnosis Code 1]

            --      LEFT OUTER JOIN
            --[LookUp].[dbo].[tbl_ICD10] AS ICD_SEC2_DIAG
            --      ON ICD_SEC2_DIAG.ICD104CD = [Secondary Diagnosis Code 2]

            --      LEFT OUTER JOIN
            --[LookUp].[dbo].[tbl_ICD10] AS ICD_SEC3_DIAG
            --      ON ICD_SEC3_DIAG.ICD104CD = [Secondary Diagnosis Code 3]

            --      LEFT OUTER JOIN
            --[LookUp].[dbo].[tbl_ICD10] AS ICD_SEC4_DIAG
            --      ON ICD_SEC4_DIAG.ICD104CD = [Secondary Diagnosis Code 4]


      UNION

SELECT



      ,[Primary Diagnosis Code]
      ,LEFT([Primary Diagnosis Code],5) AS PRIMARY_DIAGNOSIS_ICD10
        ,ICD_PRIM_DIAG.ICD104NM AS PRIMARY_DIAGNOSIS_DESC

      ,[Secondary Diagnosis Code 1]
      ,LEFT([Secondary Diagnosis Code 1],5) AS [1ST_SEC_DIAGNOSIS_ICD10]
        ,ICD_SEC1_DIAG.ICD104NM AS SEC_DIAG1ST_DESC
     
      ,[Secondary Diagnosis Code 2]
      ,LEFT([Secondary Diagnosis Code 2],5) AS [2ND_SEC_DIAGNOSIS_ICD10]
        ,ICD_SEC2_DIAG.ICD104NM AS SEC_DIAG2ND_DESC
     
      ,[Secondary Diagnosis Code 3]
      ,left([Secondary Diagnosis Code 3],5) AS [3RD_SEC_DIAGNOSIS_ICD10]
        ,ICD_SEC3_DIAG.ICD104NM AS SEC_DIAG3RD_DESC
     
      ,[Secondary Diagnosis Code 4]
      ,left([Secondary Diagnosis Code 4],5) AS [4TH_SEC_DIAGNOSIS_ICD10]
        ,ICD_SEC4_DIAG.ICD104NM AS SEC_DIAG4TH_DESC
     

      
FROM      [1112]

                  LEFT OUTER JOIN
            [LookUp].[dbo].[tbl_ICD10] AS ICD_PRIM_DIAG
                  ON ICD_PRIM_DIAG.ICD104CD = LEFT([Primary Diagnosis Code],4)

                  LEFT OUTER JOIN
            [LookUp].[dbo].[tbl_ICD10] AS ICD_SEC1_DIAG
                  ON ICD_SEC1_DIAG.ICD104CD = [Secondary Diagnosis Code 1]

                  LEFT OUTER JOIN
            [LookUp].[dbo].[tbl_ICD10] AS ICD_SEC2_DIAG
                  ON ICD_SEC2_DIAG.ICD104CD = [Secondary Diagnosis Code 2]

                  LEFT OUTER JOIN
            [LookUp].[dbo].[tbl_ICD10] AS ICD_SEC3_DIAG
                  ON ICD_SEC3_DIAG.ICD104CD = [Secondary Diagnosis Code 3]

                  LEFT OUTER JOIN
            [LookUp].[dbo].[tbl_ICD10] AS ICD_SEC4_DIAG
                  ON ICD_SEC4_DIAG.ICD104CD = [Secondary Diagnosis Code 4]
0
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 
LVL 15

Expert Comment

by:gplana
ID: 37805484
Yes, just try to remove joins now, as I have replaced the field by an empty string on the select.
0
 

Author Comment

by:aneilg
ID: 37805497
ok i'll give it a go.

i was told this approcah is possible.
Select fieldNames from (

10/11 query

Union all

11/12 query

) as subQuery
Then do all the joins here
0
 
LVL 15

Expert Comment

by:gplana
ID: 37805561
Yes, this is also possible, but isn't it better the solution I give ?

Or maybe I misunderstood the goal ?
0
 

Author Comment

by:aneilg
ID: 37805578
yeah but he is Adamant I do it his way.


but if i do

SELECT * FROM (

SELECT

      ,[Primary Diagnosis Code]
      ,LEFT([Primary Diagnosis Code],5) AS PRIMARY_DIAGNOSIS_ICD10
        ,ICD_PRIM_DIAG.ICD104NM AS PRIMARY_DIAGNOSIS_DESC
     
      ,[Secondary Diagnosis Code 1]
      ,LEFT([Secondary Diagnosis Code 1],5) AS [1ST_SEC_DIAGNOSIS_ICD10]
        ,ICD_SEC1_DIAG.ICD104NM AS SEC_DIAG1ST_DESC
     
      ,[Secondary Diagnosis Code 2]
      ,LEFT([Secondary Diagnosis Code 2],5) AS [2ND_SEC_DIAGNOSIS_ICD10]
        ,ICD_SEC2_DIAG.ICD104NM AS SEC_DIAG2ND_DESC
     
      ,[Secondary Diagnosis Code 3]
      ,left([Secondary Diagnosis Code 3],5) AS [3RD_SEC_DIAGNOSIS_ICD10]
        ,ICD_SEC3_DIAG.ICD104NM AS SEC_DIAG3RD_DESC
     
      ,[Secondary Diagnosis Code 4]
      ,left([Secondary Diagnosis Code 4],5) AS [4TH_SEC_DIAGNOSIS_ICD10]
        ,ICD_SEC4_DIAG.ICD104NM AS SEC_DIAG4TH_DESC
     

           
FROM  [0910]

            --      LEFT OUTER JOIN
            --[LookUp].[dbo].[tbl_ICD10] AS ICD_PRIM_DIAG
            --      ON ICD_PRIM_DIAG.ICD104CD = LEFT([Primary Diagnosis Code],4)

            --      LEFT OUTER JOIN
            --[LookUp].[dbo].[tbl_ICD10] AS ICD_SEC1_DIAG
            --      ON ICD_SEC1_DIAG.ICD104CD = [Secondary Diagnosis Code 1]

            --      LEFT OUTER JOIN
            --[LookUp].[dbo].[tbl_ICD10] AS ICD_SEC2_DIAG
            --      ON ICD_SEC2_DIAG.ICD104CD = [Secondary Diagnosis Code 2]

            --      LEFT OUTER JOIN
            --[LookUp].[dbo].[tbl_ICD10] AS ICD_SEC3_DIAG
            --      ON ICD_SEC3_DIAG.ICD104CD = [Secondary Diagnosis Code 3]

            --      LEFT OUTER JOIN
            --[LookUp].[dbo].[tbl_ICD10] AS ICD_SEC4_DIAG
            --      ON ICD_SEC4_DIAG.ICD104CD = [Secondary Diagnosis Code 4]

      UNION

     
SELECT  

     
      ,[Primary Diagnosis Code]
      ,LEFT([Primary Diagnosis Code],5) AS PRIMARY_DIAGNOSIS_ICD10
        ,ICD_PRIM_DIAG.ICD104NM AS PRIMARY_DIAGNOSIS_DESC
     
      ,[Secondary Diagnosis Code 1]
      ,LEFT([Secondary Diagnosis Code 1],5) AS [1ST_SEC_DIAGNOSIS_ICD10]
        ,ICD_SEC1_DIAG.ICD104NM AS SEC_DIAG1ST_DESC
     
      ,[Secondary Diagnosis Code 2]
      ,LEFT([Secondary Diagnosis Code 2],5) AS [2ND_SEC_DIAGNOSIS_ICD10]
        ,ICD_SEC2_DIAG.ICD104NM AS SEC_DIAG2ND_DESC
     
      ,[Secondary Diagnosis Code 3]
      ,left([Secondary Diagnosis Code 3],5) AS [3RD_SEC_DIAGNOSIS_ICD10]
        ,ICD_SEC3_DIAG.ICD104NM AS SEC_DIAG3RD_DESC
     
      ,[Secondary Diagnosis Code 4]
      ,left([Secondary Diagnosis Code 4],5) AS [4TH_SEC_DIAGNOSIS_ICD10]
        ,ICD_SEC4_DIAG.ICD104NM AS SEC_DIAG4TH_DESC
     

     
     
FROM [1011]

            --      LEFT OUTER JOIN
            --[LookUp].[dbo].[tbl_ICD10] AS ICD_PRIM_DIAG
            --      ON ICD_PRIM_DIAG.ICD104CD = LEFT([Primary Diagnosis Code],4)

            --      LEFT OUTER JOIN
            --[LookUp].[dbo].[tbl_ICD10] AS ICD_SEC1_DIAG
            --      ON ICD_SEC1_DIAG.ICD104CD = [Secondary Diagnosis Code 1]

            --      LEFT OUTER JOIN
            --[LookUp].[dbo].[tbl_ICD10] AS ICD_SEC2_DIAG
            --      ON ICD_SEC2_DIAG.ICD104CD = [Secondary Diagnosis Code 2]

            --      LEFT OUTER JOIN
            --[LookUp].[dbo].[tbl_ICD10] AS ICD_SEC3_DIAG
            --      ON ICD_SEC3_DIAG.ICD104CD = [Secondary Diagnosis Code 3]

            --      LEFT OUTER JOIN
            --[LookUp].[dbo].[tbl_ICD10] AS ICD_SEC4_DIAG
            --      ON ICD_SEC4_DIAG.ICD104CD = [Secondary Diagnosis Code 4]


      UNION

SELECT



      ,[Primary Diagnosis Code]
      ,LEFT([Primary Diagnosis Code],5) AS PRIMARY_DIAGNOSIS_ICD10
        ,ICD_PRIM_DIAG.ICD104NM AS PRIMARY_DIAGNOSIS_DESC

      ,[Secondary Diagnosis Code 1]
      ,LEFT([Secondary Diagnosis Code 1],5) AS [1ST_SEC_DIAGNOSIS_ICD10]
        ,ICD_SEC1_DIAG.ICD104NM AS SEC_DIAG1ST_DESC
     
      ,[Secondary Diagnosis Code 2]
      ,LEFT([Secondary Diagnosis Code 2],5) AS [2ND_SEC_DIAGNOSIS_ICD10]
        ,ICD_SEC2_DIAG.ICD104NM AS SEC_DIAG2ND_DESC
     
      ,[Secondary Diagnosis Code 3]
      ,left([Secondary Diagnosis Code 3],5) AS [3RD_SEC_DIAGNOSIS_ICD10]
        ,ICD_SEC3_DIAG.ICD104NM AS SEC_DIAG3RD_DESC
     
      ,[Secondary Diagnosis Code 4]
      ,left([Secondary Diagnosis Code 4],5) AS [4TH_SEC_DIAGNOSIS_ICD10]
        ,ICD_SEC4_DIAG.ICD104NM AS SEC_DIAG4TH_DESC
     

     
FROM      [1112]

) as g


                  LEFT OUTER JOIN
            [LookUp].[dbo].[tbl_ICD10] AS ICD_PRIM_DIAG
                  ON ICD_PRIM_DIAG.ICD104CD = LEFT([Primary Diagnosis Code],4)

                  LEFT OUTER JOIN
            [LookUp].[dbo].[tbl_ICD10] AS ICD_SEC1_DIAG
                  ON ICD_SEC1_DIAG.ICD104CD = [Secondary Diagnosis Code 1]

                  LEFT OUTER JOIN
            [LookUp].[dbo].[tbl_ICD10] AS ICD_SEC2_DIAG
                  ON ICD_SEC2_DIAG.ICD104CD = [Secondary Diagnosis Code 2]

                  LEFT OUTER JOIN
            [LookUp].[dbo].[tbl_ICD10] AS ICD_SEC3_DIAG
                  ON ICD_SEC3_DIAG.ICD104CD = [Secondary Diagnosis Code 3]

                  LEFT OUTER JOIN
            [LookUp].[dbo].[tbl_ICD10] AS ICD_SEC4_DIAG
                  ON ICD_SEC4_DIAG.ICD104CD = [Secondary Diagnosis Code 4]


i get Msg 4104, Level 16, State 1, Line 121
The multi-part identifier "ICD_PRIM_DIAG.ICD104NM" could not be bound.
0
 
LVL 15

Expert Comment

by:gplana
ID: 37805600
Ok, in this case try the other approach:

SELECT .... FROM (
                 SELECT ... (without joins)
                 UNION ALL
                 SELECT ... (without joins)
                 UNION ALL
                 SELECT ... (without joins)
) and make the joins here
0
 

Author Comment

by:aneilg
ID: 37805652
thanks for your help,

i've done

SELECT * FROM (

) as g

joins

but get Msg 4104, Level 16, State 1, Line 121
The multi-part identifier "ICD_PRIM_DIAG.ICD104NM" could not be bound.
Msg 4104, Level 16, State 1, Line 125

is this appracah possible.
0
 
LVL 15

Expert Comment

by:gplana
ID: 37805834
This is because you don't have the ICD_PRIM_DIAG table on your SELECT or because field ICD104NM is not a valid field on ICD_PRIM_DIAG table
0
 

Author Closing Comment

by:aneilg
ID: 37855755
thanks.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question