M
Mike Klein
My table contains all possible sets of 3. I'd like to select TOP N distinct sets of 3 with the lowest "S" value
i.e. DISTINCTROW TOP N, ORDER BY S. Unfortunately, that's not allowed.
My last try has potential, but thought I'd post before resuming in the morning. Details below
Any ideas would be appreciated
Thanks
Mik
My last try was to use a temporary table: FOR I = 1 TO
INSERT INTO TEMP SELECT FIRST(STORE) AS CSTORE
FROM MATCH4 WHERE STORE NOT IN (SELECT CSTORE FROM TEMP)
NEXT
Followed by Looping thru TEMP: I = DMin("", "MATCH4", "[Store] = " & !Cstore
S = DLookup("[STORE2]", "MATCH4", "[Store]= " & !Cstore & "AND= " & I
Sq = "UPDATE TEMP Set TSTORE1 = " & S & " Where CSTORE = " & !Cstore & " ;
CurrentDb.Execute S
I = DMin("", "MATCH4", "[Store] = " & !Cstore
S = DLookup("[STORE3]", "MATCH4", "[Store]= " & !Cstore & "AND= " & I
Sq = "UPDATE TEMP Set TSTORE2 = " & S & " Where CSTORE = " & !Cstore & " ;
CurrentDb.Execute S
STORE STORE2 STORE3
288 268 605 1.02490939
288 605 268 1.02490939
605 268 288 1.06386337
605 288 268 1.06386337
268 288 605 1.09620708
268 605 288 1.09620708
168 268 605 1.35165702
168 605 268 1.35165702
529 268 605 1.37674954
529 605 268 1.37674954
168 288 268 1.37743352
168 268 288 1.37743352
288 529 268 1.38099201
288 268 529 1.38099201
168 288 605 1.39853126
168 605 288 1.39853126
288 529 605 1.40154465
288 605 529 1.40154465
529 268 288 1.40217706
529 288 268 1.40217706
i.e. DISTINCTROW TOP N, ORDER BY S. Unfortunately, that's not allowed.
My last try has potential, but thought I'd post before resuming in the morning. Details below
Any ideas would be appreciated
Thanks
Mik
My last try was to use a temporary table: FOR I = 1 TO
INSERT INTO TEMP SELECT FIRST(STORE) AS CSTORE
FROM MATCH4 WHERE STORE NOT IN (SELECT CSTORE FROM TEMP)
NEXT
Followed by Looping thru TEMP: I = DMin("
S = DLookup("[STORE2]", "MATCH4", "[Store]= " & !Cstore & "AND
Sq = "UPDATE TEMP Set TSTORE1 = " & S & " Where CSTORE = " & !Cstore & " ;
CurrentDb.Execute S
I = DMin("
S = DLookup("[STORE3]", "MATCH4", "[Store]= " & !Cstore & "AND
Sq = "UPDATE TEMP Set TSTORE2 = " & S & " Where CSTORE = " & !Cstore & " ;
CurrentDb.Execute S
STORE STORE2 STORE3
288 268 605 1.02490939
288 605 268 1.02490939
605 268 288 1.06386337
605 288 268 1.06386337
268 288 605 1.09620708
268 605 288 1.09620708
168 268 605 1.35165702
168 605 268 1.35165702
529 268 605 1.37674954
529 605 268 1.37674954
168 288 268 1.37743352
168 268 288 1.37743352
288 529 268 1.38099201
288 268 529 1.38099201
168 288 605 1.39853126
168 605 288 1.39853126
288 529 605 1.40154465
288 605 529 1.40154465
529 268 288 1.40217706
529 288 268 1.40217706