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 |
vinothrao84
Starting Member
21 Posts |
Posted - 2007-10-18 : 00:19:15
|
Hi,I have the 2 following table stated below.table name : tblregfundFUND_CODE..........FUND_NAMETY..................ToyotaHO..................HondaBM...................BMWMB..................MBenzNI..................Nissan=========================================table name : tblregfundpriceFUND_CODE........FUND_PRICE..........DATETY..................2.35...................11/02/2007HO..................1.24...................22/03/2007BM..................2.53...................21/04/2007MB..................1.52...................03/08/2007NI..................4.21...................11/07/2007TY..................5.21...................25/06/2007HO..................4.22...................22/02/2007BM..................5.2...................24/01/2007MB..................1.9...................29/08/2007NI..................1.82...................27/07/2007TY..................1.66...................28/12/2007HO..................5.24...................14/11/2007BM..................1.38...................19/05/2007MB..................1.2...................17/02/2007NI..................1.11...................16/04/2007I want to get TOP 1 latest FUND_PRICE for each FUND_CODE so that it appear as below result.FUND_NAME........FUND_PRICEToyota..................5.21Honda...................5.24BMW.....................5.2MBenz...................1.9Nissan..................4.21Just TOP 1 for each FUND_PRICE. Please help.Thx. |
|
Kristen
Test
22859 Posts |
Posted - 2007-10-18 : 00:37:38
|
This perhaps?SELECT FUND_NAME, MAX(FUND_PRICE)FROM tblregfundprice AS P JOIN tblregfund AS F ON F.FUND_CODE = P.FUND_CODEGROUP BY FUND_NAME Kristen |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
|
vinothrao84
Starting Member
21 Posts |
Posted - 2007-10-18 : 03:14:45
|
quote: Originally posted by Kristen This perhaps?SELECT FUND_NAME, MAX(FUND_PRICE)FROM tblregfundprice AS P JOIN tblregfund AS F ON F.FUND_CODE = P.FUND_CODEGROUP BY FUND_NAME Kristen
Thx Kristen it's working perfectly.... |
 |
|
Kristen
Test
22859 Posts |
Posted - 2007-10-18 : 03:21:01
|
Is it homework? |
 |
|
|
|
|