Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function count2SQL(nameField,nameArr,regimSort)
- Dim i
- ReDim promACount(Ubound(nameArr),2)
- for i=0 to Ubound(nameArr)
- promACount(i,0)=nameArr(i,0)
- promACount(i,1)=0
- next
- if nameField="description_1b" then
- strsql="select description_1b,installation_area,count(*) as KOL"
- strsql=strsql & " from Lights_America..temp_products P2 "
- strsql=strsql & " left join installation_area I on (P2.description_1b=I.id)"
- strsql=strsql & whereStrSql
- strSql=strSql & " group by description_1b,installation_area"
- strSql=strSql & " order by installation_area"
- elseif nameField="description_1a" then
- strsql="select description_1a,description,count(*) as KOL"
- strsql=strsql & " from Lights_America..temp_products P2 "
- strsql=strsql & " left join description D on (P2.description_1a=D.id)"
- strsql=strsql & whereStrSql
- strSql=strSql & " group by description_1a,description"
- strSql=strSql & " order by description"
- elseIf nameField="description_5" then
- strsql="select description_5,finish,count(*) as KOL"
- strsql=strsql & " from Lights_America..temp_products P2 "
- strsql=strsql & " left join finish F on (P2.description_5=F.id)"
- strsql=strsql & whereStrSql
- strSql=strSql & " group by description_5,finish"
- strSql=strSql & " order by finish"
- elseIf nameField="manufacturer_name" then
- strsql="select manufacturer_name,M.manufacturer,S.sort,count(*) as KOL"
- strsql=strsql & " from temp_products P2 "
- strsql=strsql & " left join manufacturer M on (M.id=P2.manufacturer_name)"
- strsql=strsql & " left join sort S on (S.StoreName='" & Session("StoreName") & "' and S.man=P2.manufacturer_name)"
- strsql=strsql & whereStrSql
- strsql=strsql & " group by manufacturer_name,M.manufacturer,S.sort"
- strsql=strsql & " order by sort asc,manufacturer asc"
- ' strsql="select manufacturer_name,count(*) as KOL"
- ' strsql=strsql & " from Lights_America..temp_products P2 "
- ' strsql=strsql & whereStrSql
- ' strSql=strSql & " group by manufacturer_name"
- ' strSql=strSql & " order by KOL desc"
- elseIf nameField="voltage" then
- strsql="select P2.voltage as voltage, V.voltage as voltage2, count(*) as KOL"
- strsql=strsql & " from Lights_America..temp_products P2 "
- strsql=strsql & " left join Lights_America..voltage V on (P2.voltage=V.id)"
- strsql=strsql & whereStrSql
- strSql=strSql & " group by P2.voltage,V.voltage"
- strSql=strSql & " order by voltage2"
- elseIf nameField="pricekod" then
- strsql="select P2.pricekod,count(*) as KOL"
- strsql=strsql & " from Lights_America..temp_products P2 "
- strsql=strsql & whereStrSql
- strSql=strSql & " group by P2.pricekod"
- else
- response.write(" nameField=" & namefield)
- response.end
- end if
- string_return=""
- objRs.Open strSQL, objRsConn, 3, 1, 1
- if regimsort=0 then
- do while not objRs.EOF
- if not IsNULL(objRS(nameField)) then
- my_kod=objRS(nameField)
- for i=0 to Ubound(promACount)
- if promACount(i,0)= my_kod then
- promACount(i,1)=0+promACount(i,1)+objRs("KOL")
- TotalCount=TotalCount+objRs("KOL")
- end if
- next
- end if
- objRs.MoveNext
- loop
- for i=0 to Ubound(promACount)
- if promACount(i,1)>0 then
- string_return=string_return & promACount(i,0) & "~~" & promACount(i,1) & "~~++"
- end if
- next
- else
- do while not objRs.EOF
- if not IsNULL(objRS(nameField)) then
- string_return=string_return & objRS(nameField) & "~~" & objRS("KOL") & "~~++"
- end if
- TotalCount=TotalCount+objRs("KOL")
- objRs.MoveNext
- loop
- end if
- objRS.Close
- count2SQL=string_return
- end function
Add Comment
Please, Sign In to add comment