I wrote a simple function to create statistics from my SQL Database. It is collecting the count of orders every day. I copy the code e.g. 20 times but I think it can be easier with a repeat loop :-p
I mean for 3 days I can copy paste, no problem. But now I have to collect 50 days, 100 days etc and the code is being larger and larger..
My question: Any Ideas how can I create a repeat function around this stuff to create a variable (var_transfer_7tage, bottom of the code) for a graph without copy and copy and copy the code again?
Thanks
Stef
Code: Select all
#Statistik 3 Days
################ create the select
put "SELECT UserID, COUNT(Bestellnummer) FROM t_daten WHERE Auftragsdatum >= DATE_SUB(CURDATE(), INTERVAL 0 DAY) and UserID = '" & username_client & "' " into sql_stat7days1
################ run the query
put item 2 of revDataFromQuery(tab,return,dbid_hub,sql_stat7days1) into stat7days1
################ now put the results (no of orders for today) into sumup
put stat7days1 into sumup
################ Now: the 2nd day:
put "SELECT UserID, COUNT(Bestellnummer) FROM t_daten WHERE Auftragsdatum >= DATE_SUB(CURDATE(), INTERVAL 1 DAY) and UserID = '" & username_client & "' " into sql_stat7days2
put item 2 of revDataFromQuery(tab,return,dbid_hub,sql_stat7days2) into stat7days2
################ Calculate the Orders from this day (stat7days2 - sumup
put stat7days2 - sumup into stat7days2
################ Calculate the Orders (total) from 1st day and 2nd day)
put stat7days2 + sumup into sumup
################ Now: the 3rd day:
put "SELECT UserID, COUNT(Bestellnummer) FROM t_daten WHERE Auftragsdatum >= DATE_SUB(CURDATE(), INTERVAL 2 DAY) and UserID = '" & username_client & "' " into sql_stat7days3
put item 2 of revDataFromQuery(tab,return,dbid_hub,sql_stat7days3) into stat7days3
################ Calculate the Orders from this day (stat7days2 - sumup
put stat7days3 - sumup into stat7days3
################ Calculate the Orders (total) from 1st day, 2nd day and 3rd day)
put stat7days3 + sumup into sumup
### and again, again, again.... x many days
# Now: Create a graph
Put "0," & stat7days1 & CR into var_transfer_7tage
Put "1," & stat7days2 & CR after var_transfer_7tage
Put "2," & stat7days3 & CR after var_transfer_7tage
### and again, again, again.... x many days