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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 query syntax

Author  Topic 

eem_2055
Yak Posting Veteran

69 Posts

Posted - 2007-11-15 : 02:39:21
Hi guys<


I wan to know what command can I use to view the latest date of posting of interest in my database given the following tables

Table: DepositInterest
Fields: code1, code2, interestdate

code 1 and 2 are primary keys.
Then I tried to run a query using where clause but then it happened that all interestdate are viewed.

What I want is to just view the latest interestdate.

elancaster
A very urgent SQL Yakette

1208 Posts

Posted - 2007-11-15 : 02:53:34
select max(interestdate)
from depositInterest

Em
Go to Top of Page

eem_2055
Yak Posting Veteran

69 Posts

Posted - 2007-11-15 : 03:15:20
it's not applicable sir;

sample result that I've made is:

code1 |code2 |interestposteddate
0001 |02 |02/07/2007
0001 |02 |01/06/2006
0001 |03 |02/05/2007
0001 |03 |01/16/2006

it should be
code1 |code2 |interestposteddate
0001 |02 |02/07/2007
0001 |03 |02/05/2007

what code can I use?




Go to Top of Page

elancaster
A very urgent SQL Yakette

1208 Posts

Posted - 2007-11-15 : 03:22:07
ah... so you don't want to JUST view the last interestdate


select code1,code2,max(interestdate)
from depositInterest
group by code1,code2


Em
Go to Top of Page

eem_2055
Yak Posting Veteran

69 Posts

Posted - 2007-11-15 : 06:36:23
Thanks a lot! it really helps me..
Go to Top of Page
   

- Advertisement -