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 |
|
OldMySQLUser
Constraint Violating Yak Guru
301 Posts |
Posted - 2009-10-28 : 05:33:12
|
| I have a table:amount paymentdate clientid----- ----------- --------10.00 2009-06-20 10120012.00 2009-06-22 10033310.00 2009-06-22 10120017.50 2009-06-23 11134512.00 2009-06-23 101200how can I select the latest payment date amount for client 101200 please? |
|
|
Sachin.Nand
2937 Posts |
Posted - 2009-10-28 : 05:44:18
|
| select max(paymentdate) from table where client=101200PBUH |
 |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-10-28 : 08:05:47
|
| select amount,paymentdate,clientid from (select row_number() over(partiton by clientid order by paymentdate desc) as rid,* from tablename)swhere rid = 1 and clientid = 101200 |
 |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2009-10-28 : 10:53:54
|
| select top 1 paymentdate, amount from MyTable where clientid = 101200 order by paymentdate descCODO ERGO SUM |
 |
|
|
|
|
|