title: The column 'ID' was specified multiple times for 'PivotTable'
body: <pre><code>SELECT PartyRelationshipID,[2] AS OrderGroup,[3] AS TaxStatus,[4] AS Area
  FROM (
  SELECT prs.PartyRelationshipID
  ,prs.PartyRelationshipSettingTypeID
  ,Value = CONVERT(INT, CASE WHEN IsNumeric(CONVERT(VARCHAR(12), prs.Value)) = 1 then CONVERT(VARCHAR(12), prs.Value) else 0 End)  
  FROM [Party].PartyRelationshipSetting prs) AS SourceTable
  INNER JOIN Party.PartyRelationship prship ON SourceTable.PartyRelationshipID = prship.ID
  INNER JOIN Party.PartyRole pr ON prship.ToPartyRoleID = pr.ID
  INNER JOIN Party.Organization org ON pr.PartyID = org.PartyID
  PIVOT
  (
  SUM(Value)
  FOR PartyRelationshipSettingTypeID IN ([2],[3],[4])
  )AS PivotTable
  </code></pre>
  
  <p>I am getting</p>
  
  <blockquote>
    <p>The column 'ID' was specified multiple times for 'PivotTable'</p>
  </blockquote>
  
  <p>But in the above query I not using <code>SELECT *</code> statements or I am adding aliases for each and every ID selection to avoid conflicts. From which part this error occurs and how to fix it?</p>
  
  <p>I am getting this error when I add the below lines to the code.</p>
  
  <pre><code>INNER JOIN Party.PartyRole pr ON prship.ToPartyRoleID = pr.ID
  INNER JOIN Party.Organization org ON pr.PartyID = org.PartyID
  </code></pre>
  
  <p>And also where to pul the WHERE clause in order to only select entries based on <code>prship.ToPartyRoleID</code>. WHERE clause doesn't fit inside the or outside the PIVOT.</p>