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 |
hansalas
Starting Member
14 Posts |
Posted - 2006-08-23 : 05:53:12
|
Table One.....................Table Twoid--|-type....................type---|typeDescr1---|-100.....................100----|alpha1---|-200.....................200----|bravo1---|-101.....................400----|gamma2---|-9003---|-4003---|-100Here is an example tables... select id,max(type)from tableOnegroup by idThis is wat i am doing now... But I wanna also display the type description for the max type...select id,max(type).max(type)'s descriptionNot to complicate things at this time, there is also another table 3 which i also wanna use to display the id's desciption in the above query...Anyone knoes how can I execute this queery... Thanks in advance,fellars. |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-08-23 : 05:56:41
|
[code]SELECT t1.ID, t1.Type, t2.TypeDescr, t3.IdDescrFROM ( SELECT ID, MAX(Type) Type FROM TableOne GROUP BY ID ) t1LEFT JOIN TableTwo t2 ON t2.Type = t1.TypeLEFT JOIN TableThree t3 ON t3.ID = t1.ID[/code]Peter LarssonHelsingborg, Sweden |
 |
|
|
|
|