Sub ShowSalesBySalesPerson(MyStart As String, MyEnd As String)
Dim cursor1 As Cursor
Dim MyList As List
Dim txt As String
MyList.Initialize
txt = "SELECT Sales_Person, Store, SUM(Units_Sold), Sum(Total_Retail) AS POP FROM sales_end_user WHERE Sale_Date BETWEEN '" & MyStart & "' AND '" & MyEnd & "' GROUP BY Sales_Person ORDER BY Store"
cursor1=SQL1.ExecQuery(txt)
For i=0 To cursor1.RowCount-1
cursor1.Position=i
Dim MY_POP As String = NumberFormat2(cursor1.GetDouble("POP"), 1,2, 2,True)
MyList.Add(cursor1.GetString("Sales_Person") & TAB & cursor1.GetString("Store") & TAB & cursor1.GetString("SUM(Units_Sold)") & TAB & MY_POP )
Next
'Create a temp table and loaded it with data from the list
DBUtils.DropTable(SQL1, "temptable")
LOCALCreateSalesByPersonTempTable
For i=0 To MyList.Size -1
Dim CC() As String=Regex.Split(TAB,MyList.Get(i))
SQL1.ExecNonQuery2("INSERT INTO temptable VALUES(?,?,?,?)", CC)
Next
'Load temp table onto a webview
Dim Query As String ="SELECT * FROM temptable"
wbvQuery.LoadHtml(DBUtils.ExecuteHtml(SQL1, Query, Null, 0, True))
wbvQuery.Visible=True
End Sub