<%
msql="SELECT tblCandidati.cndID, tblLang.strLimba, tblLang.strNivel, tblCandidati.strNivelStudii, tblCandidati.strNivelCariera, tblCandidati.StrKeyWords, tblCandidati.strAniExperienta, tblCandidati.strNume, tblCandidati.strPspamSpamme, tblCandidati.strIndustry, tblExperienta.strdataInceperii, tblExperienta.strdataterminarii, tblExperienta.strPozitie, SUM(DateDiff(""m"", strDataInceperii, strDataTerminarii)) AS yearsinposition"
msql= msql & " INTO tblSearch "
msql=msql & " FROM tblCandidati, tblLang, tblExperienta WHERE"
If request.form("indID")="" then
Else
msql= msql &" tblCandidati.strIndustry="& request.form("indID") &" AND "
End if
If request.form("strLimba")="" then
Else
msql= msql &" tblLang.strLimba='"& request.form("strLimba") &"' AND "
End if
If request.form("profID")="" then
Else
msql= msql &" tblExperienta.strPozitie="& request.form("profID") &" AND "
End if
If request.form("strLocalitate")="" then
Else
msql= msql &" tblCandidati.strLocalitate='"& request.form("strLocalitate") &"' AND "
End if
If request.form("keywords")="" then
Else
msql= msql &" tblCandidati.strKeyWords ='" & request.form("keywords") & "' AND "
End if
If request.form("strCarnet")="" then
Else
msql= msql &" tblCandidati.strcarnet="& request.form("strCarnet") &" AND "
End if
msql=msql & " tblExperienta.cndID=tblCandidati.cndID AND tblLang.cndID=tblCandidati.cndID"
msql=msql & " GROUP BY tblExperienta.strDataInceperii, tblExperienta.strDataTerminarii, tblCandidati.cndID, tblLang.cndID, tblLang.strLimba, tblLang.strNivel, tblExperienta.strPozitie, tblCandidati.strNivelStudii, tblCandidati.strNivelCariera, tblCandidati.strAniExperienta, tblCandidati.strNume, tblCandidati.strPspamSpamme, tblCandidati.strIndustry, tblCandidati.StrKeyWords"
'msql=msql & " HAVING SUM(DateDiff(""yyyy"", strDataInceperii, strDataTerminarii)) >= "& start &" AND SUM(DateDiff(""yyyy"", strDataInceperii, strDataTerminarii)) <= "& strend
'Response.Write msql
Set RSS = Server.CreateObject("ADODB.Recordset")
RSS.Open msql, MyConn, 1, 3
MyConn.Execute ("SELECT cndID, strPozitie, yearsinposition INTO tblNew FROM tblSearch GROUP BY cndID, strPozitie, yearsinposition")
sql2 = "SELECT cndID, strPozitie, SUM(yearsinposition) AS yearsperposition INTO tblSUM FROM tblNew GROUP BY cndID, strPozitie"
If request.form("strStart")="" then
start=0
Else
start=request.form("strStart")*12
End if
If request.form("strEnd")="" then
strend=1000
Else
strend=request.form("strEnd")*12
End if
sql2=sql2 & " HAVING SUM(yearsinposition) >= "& start &" AND SUM(yearsinposition) <= "& strend
MyConn.Execute (sql2)
sql= "SELECT cndID, SUM(yearsperposition) AS totalExperience FROM tblSUM GROUP BY cndID"
If request.form("strTStart")="" then
tstart=0
Else
tstart=request.form("strTStart")*12
End if
If request.form("strTEnd")="" then
tstrend=1000
Else
tstrend=request.form("strTEnd")*12
End if
sql=sql & " HAVING SUM(yearsperposition) >= "& tstart &" AND SUM(yearsperposition) <= "& tstrend
Set RS = Server.CreateObject("ADODB.Recordset")
RS.Open sql, MyConn, 1, 3