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 |
icw
Constraint Violating Yak Guru
378 Posts |
Posted - 2013-05-02 : 11:56:19
|
HiI have to write a query that shows 2 columns (Name, Most Recent Activity)There are two table Table1 has the name and is the primary tableTable2 is a calendar table with many rows for each table1 row. (Although some names will have no rows in table2)SO I think it is a left joinbut I don't know how to do it. |
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2013-05-02 : 12:07:43
|
Something like this?SELECT Table1.Name, MAX(Table2.Date) AS MostRecentActivityFROM Table1LEFT OUTER JOIN Table2 ON Table1.Name = Table2.NameGROUP BY Table1.name If that doesn't help, check these links for how to ask your question in a way that makes it eaiser for us to help you: http://www.sqlservercentral.com/articles/Best+Practices/61537/http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx |
|
|
icw
Constraint Violating Yak Guru
378 Posts |
Posted - 2013-05-02 : 14:59:35
|
thanks lamprey :O) |
|
|
|
|
|