Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Back-to-back hits of lotto numbers 1

Status
Not open for further replies.

GKIL67

Technical User
Dec 1, 2009
44
Hello all, Happy Holidays!

I have a table, DRAWtbl, having the fields IDcounter, date and five number fields (each number field can have values 1-49).
I would like a function i.e. b2bhits("IDcounter", "number") that would return from the last record and up to the "IDcounter" the number of consecutive occurrences (if any) of the "number" and the date of the last occurence.

For example, the following DRAWtbl (don't mind the dashes):
IDcounter - Numbers - Date
1 5-9-18-32-33 01/01/2010
2 7-28-35-5-41 01/02/2010
3 2-7-22-33-5 01/03/2010
4 44-28-35-5-41 01/04/2010
5 22-11-14-17-33 01/05/2010
6 17-19-5-23-44 01/06/2010
7 2-7-13-28-5 01/07/2010

i.e. b2bhits(2,5) would produce:
3, 01/04/2010
2, 01/07/2010

In the last six records, the requested 5 appeared 3 times (records 2,3,4) and after a skip (on record 5) it appeared again 2 times.

As there are thousands of records, I would appreciate any assistance for an efficient way /function.
 
Dear MajP, it works nicely, speed is OK and I will consider your earlier advise... I would have replied earlier but I had this terrible cold. Issue is closed, Thank you!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top