SQLTeam.com | Weblogs | Forums

Pulling Earliest Record of a Group of Transactions


#1

What is the best way to query a table and pull the every first transaction for each customer?


#2

What is your table structure?


#3
SELECT *
FROM
(
    SELECT *, RN = ROW_NUMBER() OVER (PARTITION BY CUSTOMER ORDER BY TRANSACTION_DATE)
    FROM   a_table
) D
WHERE D.RN = 1