Viewing 3 posts - 1 through 3 (of 3 total)
This should do the trick:
select
q.AccountName
,q.INVOICE_DATE as FirstOrderDate
from (
select
AccountName
,INVOICE_DATE
,ROW_NUMBER() OVER(PARTITION BY AccountName order by date desc) as Rank_Order
from table_name
) as q
where q.Rank_Order = 1
order by q.AccountName
May 27, 2014 at 9:31 am
Classy way to handle an unfortunate occurrence. Kudos to SQLServerCentral for that. Also, SQL window functions are awesome. I recently discovered the unbounded preceding and preceding constraints, which make the...
December 5, 2013 at 6:45 am
You can save the output of a sproc into a temp table. xp_msver has a record that lists the version number. You can then parse the first portion of the...
September 18, 2012 at 10:29 am
Viewing 3 posts - 1 through 3 (of 3 total)