HiI have a query that returns duplicate values from one of the columns and I am trying to figure out how to do this without distinct. There is a call to a function to return these values in the select statement but how can you say for a certain join only return one value of each match?I joined the two tables (5 and 2) on their own and I can see the duplicate value appear after I join them. The parent child is table2 - table 5 and duplicate values are in table 5.SELECT dbo.Table1.Tab1Col1, dbo.Table2.Tab2Col1, dbo.ShowTableNumber(dbo.Table2.Number) AS Number, dbo.Table2.Tab2col2, dbo.Table2.Tab2col3, dbo.Table2.Tab2Col4, dbo.Table2.Tab2Col5, dbo.Table2.Tab2Col6, dbo.Table4.Tab4Col1, dbo.Table5.Tab5Col1, dbo.Table6.Tab6Col1, dbo.Table6.Tab6Col2FROM dbo.Table6 INNER JOIN dbo.Table5 ON dbo.Table6.Table6ID = dbo.Table5.Table6 RIGHT OUTER JOIN dbo.Table2 INNER JOIN dbo.Table4 ON dbo.Table2.pk = dbo.Table4.fk INNER JOIN dbo.Table1 ON dbo.Table2.pk = dbo.Table1.FK ON dbo.Table5.Number = dbo.Table2.Number AND dbo.Table5.pk = dbo.Table2.fk
Just wondering if there is a way to do this without distinct. Distinct does not work here, which I cannot explain to myself exactly why but I don't think it is right to use it here. Thanks for any pointersG