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 |
|
ajboss
Starting Member
2 Posts |
Posted - 2010-12-03 : 09:02:57
|
| Table A-------ID_NOUSERTable B-------ID_NOLOCATIONCREATED_DATEExample Data------------Table A--------AB1234, JBLOGGSAB1235, GBUSHTable B-------AB1234, USA, 01/01/2010AB1234, UK, 02/02/2010AB1235, GBUSH, 01/01/2010I want to select all the fields from table A and only the latest (CREATED_DATE as latest) fields from table B. For e.g.AB1234, JBLOGGS, UK, 01/01/2010AB1235, GBUSH, 01/01/2010Any ideas? |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2010-12-03 : 09:11:58
|
| select a.id_no, ...from tbla ajoin tblb bon a.id_no = b.id_nojoin (select id_no, creatred = max(created) from tblb group by id_no) bmaxon b.id_no = bmax.id_noand b.created = bmax.created==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
ajboss
Starting Member
2 Posts |
Posted - 2010-12-03 : 09:20:42
|
| Thank you very much. Works perfect. |
 |
|
|
|
|
|
|
|