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.
| Author |
Topic |
|
itsme_4ucz
Starting Member
2 Posts |
Posted - 2006-09-09 : 11:57:48
|
| I have four tables with t1 t2 t3 & t4, i join them using left outer join.The join is based on foriegn key (4 columns)thats t1.column1=t2.column1 t1.column2=t2.column2 t1.column3=t2.column3t1.column4=t2.column4.Table t1 is the main table having one row per item so is t2 and t3but t4 has multiple rows for the same item.This query is resulting in the same item being listed the no of times it exists in table t4. I need to use distinct in a way it avoids the item bieng listed more than once, ie distinct based on the foreign key. that is only one row from t4.is this possible? |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2006-09-09 : 15:02:14
|
| Which row from t4 do you want?is there a unique col in t4where t4.uniquecol = (select max(t4b.uniquecol) from table4 t4b where t4b.col1 = t4.col1 and t4b.col2 = t4.col2 and ...)==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
chiragkhabaria
Master Smack Fu Yak Hacker
1907 Posts |
Posted - 2006-09-10 : 01:31:03
|
| Can you post the Table Structure for Table4 and Table1, and the relation between themChirag |
 |
|
|
|
|
|