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 |
|
blast
Starting Member
9 Posts |
Posted - 2007-01-03 : 14:53:01
|
| i have 2 tables in join and i need to take only the latest record , i'm not bale to use top feature in the join tableselect a.t1, b.t2, c.t3 from table t1inner join table t2 in a.t1= b.t2where c.t3 in('A', 'B')order by c.t3, a.t1 ascnow the result has two or more issues pulling from t2 table, i just want a single top most record to be pulledplease, help me....i tried a lot with (top, first, inner select statement)i think im totally wrong...please help thanks so much for your help in advance |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-01-03 : 14:55:51
|
| What is "latest record"?Also, if you want your problem solved faster, please provide some same data too and your expected output based on the provided sample data.Peter LarssonHelsingborg, Sweden |
 |
|
|
blast
Starting Member
9 Posts |
Posted - 2007-01-03 : 15:04:24
|
| thks for your immediate responseim getting output like this-- for each id the inner joining table has several subtransactions for that is so...there are number of entries for the same id....but i wanted the top record means the latest record from that tablea b c12 12 A12 12 B12 12 A14 14 A14 14 B16 16 B16 16 B16 16 A16 16 AI WANTED A RESULT SOMETHIGN LIKE THISa b c12 12 A14 14 A16 16 Bthanks in advance |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-01-03 : 15:35:08
|
| select col1, col2, max(col3)from <YourTableNameHere>group by col1, col2order by col1, col2If this is not good enough, you must provide some kind of timeline instrument to the table, such as an identity column, or datetime information.Peter LarssonHelsingborg, Sweden |
 |
|
|
blast
Starting Member
9 Posts |
Posted - 2007-01-03 : 15:51:04
|
| select col1, col2, max(col3)from <YourTableNameHere>group by col1, col2 order by col1, col2---this will not work i have two tables joining and i wanted the top most record in the inner table the similarity between these two tables is the issue no only ...there is last modification date filed in inner joining table..but there are more than on entry filed on the same date ...so no luck using it...i need to pick the top most record from the joining tableplease..i would appreciate any help thanks |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-01-04 : 02:52:49
|
| Post DDL for tables here.Peter LarssonHelsingborg, Sweden |
 |
|
|
|
|
|
|
|