Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

get latest by each client

Posted on 2011-02-12
2
Medium Priority
?
313 Views
Last Modified: 2012-05-11
I want to get the latest grouping by idx of each bank.
result like this
2011-02-11 11:08:32.700 BOFA   BANK OF AMERICA
2011-01-11 11:09:32.700 CHS     CHASE BANK
2011-02-12 11:09:32.700 AMC     AMERICAN HOME

Here is a sample table





MODIFIED DATE                IDX       BANK_NAME
2011-02-10 11:07:32.700 BOFA   BANK OF AMERICA
2011-02-11 11:08:32.700 BOFA   BANK OF AMERICA
2011-01-10 11:09:32.700 AMC     AMERICAN HOME
2011-01-10 11:09:32.700 CHS     CHASE BANK
2011-01-10 11:09:32.700 AMC     AMERICAN HOME
2011-02-11 11:09:32.700 BOFA   BANK OF AMERICA
2011-01-11 11:09:32.700 CHS     CHASE BANK
2011-02-12 11:09:32.700 AMC     AMERICAN HOME
0
Comment
Question by:VBdotnet2005
2 Comments
 
LVL 9

Accepted Solution

by:
ezraa earned 2000 total points
ID: 34881510
You can select the max(date) and group by the IDX and BANK_NAME field:

select max([MODIFIED DATE]), IDX,  BANK_NAME
from MyTable
group by IDX,  BANK_NAME;


If you can have different BANK_NAMEs for a IDX you may need a query similar to this one to achive the output you're looking for:

select t.[MODIFIED DATE], t.IDX,  t.BANK_NAME
from (
   select IDX, max([MODIFIED DATE]) as [MODIFIED DATE]
   from myTable group by IDX
) as m inner join MyTable t on m.IDX = t.IDX and m.[MODIFIED DATE] = t.[MODIFIED DATE]

0
 

Author Comment

by:VBdotnet2005
ID: 34881527
thank you so much
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Microsoft Access has a limit of 255 columns in a single table; SQL Server allows tables with over 255 columns, but reading that data is not necessarily simple.  The final solution for this task involved creating a custom text parser and then reading…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

877 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question