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 |
matt.orme
Starting Member
23 Posts |
Posted - 2008-11-24 : 16:49:58
|
I have a simple table that I need to run what seems to me to be a complicated query. Here's an example of the data:Table Name: History- Ticket (Text)- / - SKU (Text)-212624 / 10891780212624 / 10947210212624 / 11019510212624 / 10231260212628 / 013770212628 / 151200212628 / 11019590212628 / 11006830212628 / 11006970212632 / 10074980212632 / 10268530212632 / 10268540212634 / 10952040212636 / 12288212636 / 61805810212636 / 10483840212636 / 10223150212636 / 10843574212636 / 11051290212636 / 10313260212636 / 10952744212636 / 10359700Ticket here represents a single transaction with a single customer, while SKU represents the items they purchased. I need to determine which items were purchased most frequently with each SKU - perhaps the top 10. Ideally, this would populate another table with the "Main" SKU acting as a unique identifier for the row and 10 subsequent fields with one SKU per container in descending order of occurrence from columns 2 through 11.Doing this for a single SKU is easy, but getting everything squared away for each unique SKU stumps me. It seems like a For Each loop of some kind, but I am not good with any of that...Any help would be appreciated. Please let me know what vital info I left out, as I always seem to forget something.Thank you*EDIT* - Don't know if this matters, but a SKU only appears once on any given Ticket. |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
|
matt.orme
Starting Member
23 Posts |
Posted - 2008-11-24 : 18:31:43
|
Yes. Totally sorry. I think that I flubbed up when I put it in the "New to SQL Server" section. |
 |
|
matt.orme
Starting Member
23 Posts |
Posted - 2008-11-26 : 18:37:45
|
I got some replies to this issue in my original post, but I believe that they will only work for SQL Server. I am limited to getting this job done in Access 2003. Any help would be greatly appreciated.Happy Thanksgiving |
 |
|
|
|
|