I'm still a novice with SQL queries but I'm needing assistance with a query that is giving me some trouble for a report.
Here's some sample data
Customer | Transaction | TranDate | InvoiceAmt
1 NBS 01/01/2011 1000
1 UPD 02/01/2011 500
1 UPD 03/01/2011 100
1 UPD 04/01/2011 200
1 UPD 05/01/2011 100
2 RWL 01/01/2011 800
2 UPD 02/01/2011 350
2 CNL 03/01/2011 400
3 RWL 01/01/2011 500
3 NBS 02/01/2011 500
What I'm needing to do is to query all rows where the customers with the first appearance or oldest Transactions = NBS. I don't need the NBS row by itself, I need the resultant set where the first row is equal to NBS and then all other rows for that customer as well.
In the example below the query would return all rows for customer #1 only because the oldest entry is NBS.
Can I do this with a "sub select" statement in my query (not sure if this is the right term)...
(this is rough but just to convey the idea of what I'm trying to get)
Select Customer, Transaction, TranDate, InvoiceAmt
Select First(transaction) = 'NBS'