Lead Sources Report write(WriteCustomSelections())

var TotalCount = 0.00; var TotalCurrent = 0.00; var TotalPlan = 0.00; cursor = database.cursor( "SELECT Count(*) TotalCount, SUM(CurrentSales) TotalCurrent, "+ "SUM(PlanSales) TotalPlan "+ "FROM SalesInformation "); while( cursor.next() ) { TotalCount = cursor.TotalCount; TotalCurrent = cursor.TotalCurrent; TotalPlan= cursor.TotalPlan; } cursor.close(); cursor = database.cursor( "SELECT LeadName, Count(*) Cnt, "+ " SUM(s.PlanSales) SumPS, "+ " SUM(s.CurrentSales) SUMCS "+ " FROM LeadSources l, Salesinformation s, Customer c, Product p "+ " WHERE l.LeadID = c.LeadID AND s.CustID=c.CustID "+ " AND s.ProdID = p.ProdID "+ BuildQuery(client.CustID, client.ProdID, client.CustGroupID, client.ProdGroupID)+ " GROUP BY c.LeadID, LeadName "); while( cursor.next() ) { write(""); write(" "); write(" "); write(" "); write(" "); write(" "); write(" "); write(" "); write(""); } cursor.close();
Source Type # of Leads Planned Revenue
YTD
Actual Revenue
YTD
% of Total Leads
YTD
% of Planned Revenue
YTD
% of Actual Revenue
YTD
" + cursor.LeadName + "" + cursor.Cnt + "$" + NRound(cursor.SumPS, 0) + "$" + NRound(cursor.SumCS, 0) + " " + NRound(((cursor.Cnt/TotalCount) * 100), 2) + "%" + " " + NRound(((cursor.SumPS/TotalPlan) * 100), 2) + "%" + " " + NRound(((cursor.SumCS/TotalCurrent) * 100), 2) + "%" + "