Microsoft
Software
Hardware
Network
Question : SQL selection
I have a table, example below
PK M_ID Arrival_Date Dept
01 1 01/06/08 P1234
02 1 01/05/08 Q1232
03 3 02/04/09 P1234
04 4 01/05/08 K9999
05 4 01/05/09 Kqwew
I would like to pick of the most current Dept code for each M_ID. As you can see there can be multiple entries for each M_ID so I am not sure how to do this.
The results I am after should be something like:
PK M_ID Arrival_Date Dept
01 1 01/06/08 P1234
03 3 02/04/09 P1234
05 4 01/05/09 Kqwew
can anybody help?
Answer : SQL selection
select a.pk,a.m_id,a.arrival_date
,a.dept
from YourTable a
join (select m_id,max(arrival_date) mx_arrival_date from yourtable group by m_id) b
on a.m_id=b.m_id
and a.arrival_date = mx_arrival_date.mx_arrival
_date
Random Solutions
Which objects and in which sqluence application using DB Objects
BIOS configuration
Communication problem between TrendMicro IMSS 7.0 and SendMail
getting error Can't call method "mail" on an undefined value
Ramdom User Profile Corruption Upon Login.
Added new domain controller and Netlogon and sysvol are not shared.
Using Flash CS3, tweened photos animate slightly rippled. Why? How do I fix this?
Is there a way to prevent permanent deletion of email by a user within Exchange 2007 or Outlook 2003?
check reporting services version using SQL
Record Selection on the Latest Year