mikedaruke
Technical User
I need some help taking a table with the following
Client_name, Store_name, product, date
Bob, Joes Cars, Oil, 3/01/08
Bob, Joes Cars, Oil, 4/07/08
Bob, Joes Cars, Oil, 5/08/08
Bob, Joes Cars, Oil, 5/25/08
Bob, Joes Cars, Oil, 6/10/08
Chris,Joes Cars, Oil, 3/10/08
Chris,Joes Cars, Oil, 3/28/08
etc
I want to somehow join the table to itself, and find out the how long before the person came back. But a unique entity is Store_name/Client_name/Product.
So I want my results to look like this
Client_name, Store_name, Product, date, next_return
Bob, Joes Cars, Oil, 3/01/08, 4/07/08
Bob, Joes Cars, Oil, 4/07/08, 5/08/08
Bob, Joes Cars, Oil, 5/08/08, 5/25/08
Bob, Joes Cars, Oil, 5/25/08, 6/10/08
Bob, Joes Cars, Oil, 6/10/08, Null
Chris,Joes Cars, Oil, 3/10/08, 3/28/08
Chris,Joes Cars, Oil, 3/28/08, Null
My problem is the table has like 15,000 clients, and total of like 400,000 rows. so its huge and my querys never complete. Not sure what to do, join it, or run a subquerys. Can anyone help?
Client_name, Store_name, product, date
Bob, Joes Cars, Oil, 3/01/08
Bob, Joes Cars, Oil, 4/07/08
Bob, Joes Cars, Oil, 5/08/08
Bob, Joes Cars, Oil, 5/25/08
Bob, Joes Cars, Oil, 6/10/08
Chris,Joes Cars, Oil, 3/10/08
Chris,Joes Cars, Oil, 3/28/08
etc
I want to somehow join the table to itself, and find out the how long before the person came back. But a unique entity is Store_name/Client_name/Product.
So I want my results to look like this
Client_name, Store_name, Product, date, next_return
Bob, Joes Cars, Oil, 3/01/08, 4/07/08
Bob, Joes Cars, Oil, 4/07/08, 5/08/08
Bob, Joes Cars, Oil, 5/08/08, 5/25/08
Bob, Joes Cars, Oil, 5/25/08, 6/10/08
Bob, Joes Cars, Oil, 6/10/08, Null
Chris,Joes Cars, Oil, 3/10/08, 3/28/08
Chris,Joes Cars, Oil, 3/28/08, Null
My problem is the table has like 15,000 clients, and total of like 400,000 rows. so its huge and my querys never complete. Not sure what to do, join it, or run a subquerys. Can anyone help?