MouseHunger MouseHunger - 4 months ago 18
SQL Question

Ambiguous column name error SQL

I am receiving the error 'Ambiguous column name 'ClaimID' for the following:

USE ERSBI_Claims_Warehouse
GO

SELECT
ClaimID AS vClaimID,
DevelopmentTimeID AS vDevelopmentTimeID,
UnderwritingYear AS vUnderwritingYear,
IncurredClaimCount AS vIncurredClaimCount,
PaidClaimCount AS vPaidClaimCount,
EstimateClaimCount AS vEstimateClaimCount

FROM
FactClaimSnapshotbreakdownClaimCount as fcbscc

INNER JOIN ERSBI_Warehouse.dbo.FactClaimAccidentYear AS fcay
ON fcbscc.ClaimID = fcay.ClaimID

WHERE
fcbscc.BreakdownIntermediateLevel = 'TPP'
AND UnderwritingYear > 2013


I am very new to SQL however I think I have included all of the relevant table names. Can someone please tell me where I am going wrong? Thank you in advance

Answer

You are selecting just ClaimId in your SELECT statement, but you have multiple tables with ClaimId in it.

You need to tell it which table you're pulling from.

Based on your join:

fcbscc.ClaimID = fcay.ClaimID

Doing either

SELECT fcbscc.ClaimID 

or

SELECT fcay.ClaimID

will suffice

Comments