hello
I'm having trouble writing SQL to do the following...
Given qryRawData:
SET TH TA
1 A C
1 B F
1 E D
2 D B
2 F A
etc...
This query has 3 rows for each SET (1 to 120), giving 360 rows.
Each SET will use the distinct letters A to F, three from column TH and three from column TA.
Using this query, I need to write SQL to fill the entries of a table (tblOrderedData) like this...
PK is Autonumber
PK SET GRP Code
1 1 A 0
2 1 B 0
3 1 C -2
4 1 D 1
5 1 E 0
6 1 F -4
7 2 A 5
8 2 B 2
etc...
The rules are:
a) in the table, there are 6 rows for each SET value.
b) the GRP values are always A to F, in ascending order.
c) if GRP came from the query's TH field, Code = 0.
if GRP came from the query's TA field, Code = ASC(TH)-ASC(TA).
I can do all of this in VBA, but I'd really like to see an SQL solution. It's a bit beyond my skill level.
Thank you
I'm having trouble writing SQL to do the following...
Given qryRawData:
SET TH TA
1 A C
1 B F
1 E D
2 D B
2 F A
etc...
This query has 3 rows for each SET (1 to 120), giving 360 rows.
Each SET will use the distinct letters A to F, three from column TH and three from column TA.
Using this query, I need to write SQL to fill the entries of a table (tblOrderedData) like this...
PK is Autonumber
PK SET GRP Code
1 1 A 0
2 1 B 0
3 1 C -2
4 1 D 1
5 1 E 0
6 1 F -4
7 2 A 5
8 2 B 2
etc...
The rules are:
a) in the table, there are 6 rows for each SET value.
b) the GRP values are always A to F, in ascending order.
c) if GRP came from the query's TH field, Code = 0.
if GRP came from the query's TA field, Code = ASC(TH)-ASC(TA).
I can do all of this in VBA, but I'd really like to see an SQL solution. It's a bit beyond my skill level.
Thank you