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 |
|
cindylee
Yak Posting Veteran
55 Posts |
Posted - 2006-06-19 : 20:49:22
|
| I have 2 tables joined by CID valuetable 1pid cid 1 a12 a23 a3table 2pid cid cNo1 a1 200602 a1 200613 a1 200634 a2 508005 a2 508016 a3 50900I want the following output (Inner join by cid and display only the highest CNO for each cid)a1 20063a2 50801a3 50900ThanksCindy |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-06-19 : 21:13:15
|
[code]select t2.cid, max(t2.cNo)from table1 t1 inner join table2 t2on t1.cid = t2.cidgroup by t2.cid[/code] KH |
 |
|
|
CSK
Constraint Violating Yak Guru
489 Posts |
Posted - 2006-06-19 : 23:24:57
|
| SELECT a.cid, MAX(a.cNo)FROM tbl1 b INNER JOIN tbl2 a ON b.cid = b.cidGROUP BY b.cid-- KK |
 |
|
|
|
|
|