Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Amaranthix
Starting Member
7 Posts |
Posted - 2008-09-18 : 09:31:15
|
| Hi, this is my first time posting here and this is probably a very newbie question, but I've only been writing SQL for about a year and am self-taught.I'm using SQL Server 2005 and have 2 tables:CustomerTable C (CustomerID is the PK)TransactionTable T (TransactionID is the PK)I created a table (master) joining these two with all records and the following fields using a specific date range and some suppression flags:CustomerID, StoreID, Purchase_Date, Cashier_Number, TransactionIDFor what I'm trying to do I need the TOP 5 TransactionIDs by Purchase_Date, by StoreID, CustomerID, by Cashier_Number.So essentially I'm trying to create this:CustomerID TransactionID1 11 21 31 41 52 62 72 82 92 10If you need any additional information let me know, I'll be checking the forums today and trying to figure this out on my own. |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-09-18 : 09:36:20
|
| http://sqlblogcasts.com/blogs/madhivanan/archive/2008/09/12/return-top-n-rows.aspxMadhivananFailing to plan is Planning to fail |
 |
|
|
Amaranthix
Starting Member
7 Posts |
Posted - 2008-09-18 : 09:44:13
|
| This looks like exactly what I need, thank you very, very much. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-09-18 : 09:49:46
|
quote: Originally posted by Amaranthix This looks like exactly what I need, thank you very, very much.
You are welcome MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|
|