var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: Removing duplicate rows from query, a little help please...
I have a query that produces duplicate rows.
It is a more complex query, but the join involved is on just two tables.
The main table
Main table has a row for each record.
Each record can have 0 to 2 types of impacts, which are held in the Impact Table, joined to the main table on
main.id = impact.main_id
When I run this query against a record that has both a Client and Internal I get two lines.
I am using the following select to extract two columns.
But I get two rows, one saying Yes for Client and No for Internal and VV
CASE WHEN dbo.tbl_IPM_IncidentImpact.Impact_Type = 1 THEN 'Yes' ELSE 'No' END as 'Client Impact',
CASE WHEN dbo.tbl_IPM_IncidentImpact.Impact_Type = 2 THEN 'Yes' ELSE 'No' END as 'Internal Impact'
The join is here.
Is there anyway of getting the values into the two fields, but on the same line.
dbo.tbl_IPM_IncidentImpact on -- To get the Impact Types
dbo.tbl_IPM_IncidentMain.IM_ID = dbo.tbl_IPM_IncidentImpact.Impact_IncidentID
Wrap your CASE expressions in a MAX() aggregate function and group on the rest of the columns
Thanks for the reply, this works on it's own in a query, but not in the more complex one.
Maybe it's to do with the remainder of the joins. I'll test next week.