I have a unique problem I have come across and was hoping someone could help me out. I have changed the data for security reasons but the logic still holds true.
I have a table with the following setup...
ID Category Value ProcessDate
-----------------------------------
1 1 12 1900-01-01 00:00:00.000
2 1 13 1900-01-01 00:00:00.000
3 1 14 1900-01-01 00:00:00.000
4 1 15 1900-01-01 00:00:00.000
5 1 16 1900-01-01 00:00:00.000
6 1 23 1900-01-01 00:00:00.000
7 1 24 1900-01-01 00:00:00.000
8 1 25 1900-01-01 00:00:00.000
9 1 26 1900-01-01 00:00:00.000
10 1 34 1900-01-01 00:00:00.000
11 1 35 1900-01-01 00:00:00.000
etc.... note....value increases in a pattern where the 10's value (here 2 and 3 ) start being paired with a number 1 higher than itself and continues to 6 and starts again with another order of 10. This goes until ID value goes to 15.
Now, what I am trying to do is write a looping function with SQL that would build off itself, meaning after every pass, the SQL query would change to accomodate the rule I am looking for.
a) The rule: the values within an order of 10 (the teen values, the twenty values, the thirty values) must have a process date
such that a value as 2 in [ ID 1 value 12 week1] cannot be represented in the same process date week, it can however be chosen for a following week [ ID 6 value 23 week2].
Thus no single digit in a value can have a processdate less than a week's difference.
Example.... I have manually determined the 1st two process weeks.
ID Category Value ProcessDate
-----------------------------------
1 1 12 2002-11-03 00:00:00.000
2 1 13 1900-01-01 00:00:00.000
3 1 14 1900-01-01 00:00:00.000
4 1 15 1900-01-01 00:00:00.000
5 1 16 2002-10-27 00:00:00.000
6 1 23 1900-01-01 00:00:00.000
7 1 24 2002-10-27 00:00:00.000
8 1 25 1900-01-01 00:00:00.000
9 1 26 1900-01-01 00:00:00.000
10 1 34 1900-01-01 00:00:00.000
11 1 35 2002-10-27 00:00:00.000
12 1 36 1900-01-01 00:00:00.000
13 1 45 2002-11-03 00:00:00.000
14 1 46 1900-01-01 00:00:00.000
15 1 56 2002-11-03 00:00:00.000
So far I am stuck with the following...
set rst4 = Server.CreateObject("ADODB.Recordset"
sql4="select * from rb1 where value like '%"&n&"%'"
For n=1 to 15 ' the max value of ID
thisstringarray2=thisstring
response.write thisstringarray2 & "<BR>"
thisarray2=split(thisstring,","
If IsArray(thisarray2) then
'response.write UBound(thisarray2)
For p=0 to UBound(thisarray2)
If len(trim(thisarray2(p)))=0 then
'do nothing
Else
' sql4=sql4 & " and value not like '%"&thisarray2(p)&"%' "
sql4=sql4 & "and value not like '%"&thisarray2(p)&"%'"
End IF
Next
End IF
sql4=sql4&" and processdate !='"&theprocessdate&"' "
sql4=sql4&" order by ID DESC"
...
thisstring=thisstring&myarray(0)&","&myarray(1)&","
myarray=split(rst4("value"
,"-"
Next
-------------------------------------------------
Does anyone know how to accomplish this...?
japes
I have a table with the following setup...
ID Category Value ProcessDate
-----------------------------------
1 1 12 1900-01-01 00:00:00.000
2 1 13 1900-01-01 00:00:00.000
3 1 14 1900-01-01 00:00:00.000
4 1 15 1900-01-01 00:00:00.000
5 1 16 1900-01-01 00:00:00.000
6 1 23 1900-01-01 00:00:00.000
7 1 24 1900-01-01 00:00:00.000
8 1 25 1900-01-01 00:00:00.000
9 1 26 1900-01-01 00:00:00.000
10 1 34 1900-01-01 00:00:00.000
11 1 35 1900-01-01 00:00:00.000
etc.... note....value increases in a pattern where the 10's value (here 2 and 3 ) start being paired with a number 1 higher than itself and continues to 6 and starts again with another order of 10. This goes until ID value goes to 15.
Now, what I am trying to do is write a looping function with SQL that would build off itself, meaning after every pass, the SQL query would change to accomodate the rule I am looking for.
a) The rule: the values within an order of 10 (the teen values, the twenty values, the thirty values) must have a process date
such that a value as 2 in [ ID 1 value 12 week1] cannot be represented in the same process date week, it can however be chosen for a following week [ ID 6 value 23 week2].
Thus no single digit in a value can have a processdate less than a week's difference.
Example.... I have manually determined the 1st two process weeks.
ID Category Value ProcessDate
-----------------------------------
1 1 12 2002-11-03 00:00:00.000
2 1 13 1900-01-01 00:00:00.000
3 1 14 1900-01-01 00:00:00.000
4 1 15 1900-01-01 00:00:00.000
5 1 16 2002-10-27 00:00:00.000
6 1 23 1900-01-01 00:00:00.000
7 1 24 2002-10-27 00:00:00.000
8 1 25 1900-01-01 00:00:00.000
9 1 26 1900-01-01 00:00:00.000
10 1 34 1900-01-01 00:00:00.000
11 1 35 2002-10-27 00:00:00.000
12 1 36 1900-01-01 00:00:00.000
13 1 45 2002-11-03 00:00:00.000
14 1 46 1900-01-01 00:00:00.000
15 1 56 2002-11-03 00:00:00.000
So far I am stuck with the following...
set rst4 = Server.CreateObject("ADODB.Recordset"
sql4="select * from rb1 where value like '%"&n&"%'"
For n=1 to 15 ' the max value of ID
thisstringarray2=thisstring
response.write thisstringarray2 & "<BR>"
thisarray2=split(thisstring,","
If IsArray(thisarray2) then
'response.write UBound(thisarray2)
For p=0 to UBound(thisarray2)
If len(trim(thisarray2(p)))=0 then
'do nothing
Else
' sql4=sql4 & " and value not like '%"&thisarray2(p)&"%' "
sql4=sql4 & "and value not like '%"&thisarray2(p)&"%'"
End IF
Next
End IF
sql4=sql4&" and processdate !='"&theprocessdate&"' "
sql4=sql4&" order by ID DESC"
...
thisstring=thisstring&myarray(0)&","&myarray(1)&","
myarray=split(rst4("value"
Next
-------------------------------------------------
Does anyone know how to accomplish this...?
japes