Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Query Problem

Author  Topic 

viperbyte
Posting Yak Master

132 Posts

Posted - 2013-06-07 : 11:04:07
Good morning everybody,

I'm stuck in linking two tables correctly for a Crystal Report. I have a table named CreditHeader and another table named CreditDetail. They both have a field called CrUniqueID. The CreditDetail table for example may have four rows with the same value for the column CrUniqueID like 8keb44, 8keb44, 8keb44, 8keb44. And those four rows will have the same value for a column such as CrTotal, like $25.25, $25.25, $25.25, $25.25. The CreditHeader table will have ONE row with the value 8keb44 for the column CrUniqueID and the value $25.25 for CrTotal. When I join these two tables on the CrUniqueID column, I'll get four rows in the result set with the column CrUniqueID having 8keb44 and CrTotal having $25.25. I need to link the two tables because table CreditDetail has one column with information that is needed which is not in the CreditHeader table. The column is called "Item". If it wasn't for that the I wouldn't have to link these two tables and would be happy with the CreditHeader table as is. Is there a way to get "Item" from the CreditDetail table and not have the repeated rows? It should be just one row per CrUniqueID in the result set. Can someone super please show me how to do this, if this is even possible?

djj55
Constraint Violating Yak Guru

352 Posts

Posted - 2013-06-07 : 14:10:35
Since you did not show any t-sql, have you tried DISTINCT and/or a CTE?

djj
Go to Top of Page

viperbyte
Posting Yak Master

132 Posts

Posted - 2013-06-07 : 16:20:01
Yeah but this bit of the project has been scrapped. Thanks anyway.
Go to Top of Page
   

- Advertisement -