Guest User

Untitled

a guest
Sep 4th, 2018
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ASP 3.70 KB | None | 0 0
  1. function count2SQL(nameField,nameArr,regimSort)
  2. Dim i
  3. ReDim promACount(Ubound(nameArr),2)
  4. for i=0 to Ubound(nameArr)
  5. promACount(i,0)=nameArr(i,0)
  6. promACount(i,1)=0
  7. next
  8. if nameField="description_1b" then
  9.     strsql="select description_1b,installation_area,count(*) as KOL"
  10.     strsql=strsql & " from Lights_America..temp_products P2 "
  11.     strsql=strsql & " left join  installation_area I on (P2.description_1b=I.id)"
  12.     strsql=strsql & whereStrSql
  13.     strSql=strSql & " group by description_1b,installation_area"
  14.     strSql=strSql & " order by installation_area"
  15. elseif nameField="description_1a" then
  16.     strsql="select description_1a,description,count(*) as KOL"
  17.     strsql=strsql & " from Lights_America..temp_products P2 "
  18.     strsql=strsql & " left join  description D on (P2.description_1a=D.id)"
  19.     strsql=strsql & whereStrSql
  20.     strSql=strSql & " group by description_1a,description"
  21.     strSql=strSql & " order by description"
  22. elseIf nameField="description_5" then
  23.     strsql="select description_5,finish,count(*) as KOL"
  24.     strsql=strsql & " from Lights_America..temp_products P2 "
  25.     strsql=strsql & " left join  finish F on (P2.description_5=F.id)"
  26.     strsql=strsql & whereStrSql
  27.     strSql=strSql & " group by description_5,finish"
  28.     strSql=strSql & " order by finish"
  29. elseIf nameField="manufacturer_name" then
  30.     strsql="select manufacturer_name,M.manufacturer,S.sort,count(*) as KOL"
  31.     strsql=strsql & " from temp_products P2 "
  32.     strsql=strsql & " left join manufacturer M on (M.id=P2.manufacturer_name)"
  33.     strsql=strsql & " left join sort S on (S.StoreName='" & Session("StoreName") & "' and S.man=P2.manufacturer_name)"
  34.     strsql=strsql & whereStrSql
  35.     strsql=strsql & " group by manufacturer_name,M.manufacturer,S.sort"
  36.     strsql=strsql & " order by sort asc,manufacturer asc"
  37. '   strsql="select manufacturer_name,count(*) as KOL"
  38. '   strsql=strsql & " from Lights_America..temp_products P2 "
  39. '   strsql=strsql & whereStrSql
  40. '   strSql=strSql & " group by manufacturer_name"
  41. '   strSql=strSql & " order by KOL desc"
  42. elseIf nameField="voltage" then
  43.     strsql="select P2.voltage as voltage, V.voltage as voltage2, count(*) as KOL"
  44.     strsql=strsql & " from Lights_America..temp_products P2 "
  45.     strsql=strsql & " left join Lights_America..voltage V on (P2.voltage=V.id)"
  46.     strsql=strsql & whereStrSql
  47.     strSql=strSql & " group by P2.voltage,V.voltage"
  48.     strSql=strSql & " order by voltage2"
  49. elseIf nameField="pricekod" then
  50.     strsql="select P2.pricekod,count(*) as KOL"
  51.     strsql=strsql & " from Lights_America..temp_products P2 "
  52.     strsql=strsql & whereStrSql
  53.     strSql=strSql & " group by P2.pricekod"
  54. else
  55. response.write("  nameField=" & namefield)
  56. response.end
  57. end if
  58. string_return=""
  59.         objRs.Open strSQL, objRsConn, 3, 1, 1
  60. if regimsort=0 then
  61.         do while not objRs.EOF
  62.                 if not IsNULL(objRS(nameField)) then
  63.                         my_kod=objRS(nameField)
  64.                         for i=0 to Ubound(promACount)
  65.                         if promACount(i,0)= my_kod  then
  66.                                 promACount(i,1)=0+promACount(i,1)+objRs("KOL")
  67. TotalCount=TotalCount+objRs("KOL")
  68.                         end if
  69.                         next
  70.                 end if
  71.                 objRs.MoveNext
  72.         loop
  73.         for i=0 to Ubound(promACount)
  74.                 if promACount(i,1)>0 then
  75. string_return=string_return & promACount(i,0) & "~~" & promACount(i,1) & "~~++"
  76.                 end if
  77.         next
  78. else
  79.         do while not objRs.EOF
  80.                 if not IsNULL(objRS(nameField)) then
  81. string_return=string_return & objRS(nameField) & "~~" & objRS("KOL") & "~~++"
  82.                 end if
  83. TotalCount=TotalCount+objRs("KOL")
  84.                 objRs.MoveNext
  85.         loop
  86. end if
  87.         objRS.Close
  88. count2SQL=string_return
  89. end function
Add Comment
Please, Sign In to add comment