202 lines
5.8 KiB
Plaintext
202 lines
5.8 KiB
Plaintext
<!--#include Virtual="/Lib/config.asp" -->
|
|
<%
|
|
Dim SQl, objdb
|
|
set Objdb = Server.CreateObject("ADODB.Recordset")
|
|
Dim gubun : gubun = Request("gubun")
|
|
dim json
|
|
dim iCnt
|
|
Dim json_arr1, json_arr2
|
|
Dim gender, district, allDate, gDate
|
|
|
|
|
|
Select case gubun
|
|
|
|
case "FirstEdu"'조사 참석 가능자
|
|
DBConnect()
|
|
|
|
SQL = ""
|
|
SQL = SQL&" SELECT [1] as lCnt, [2] as mCnt, [3] as fCnt, [4] as sCnt, [1]+[2]+[3]+[4] as tcnt FROM "&VbCrlf
|
|
SQL = SQL&" ( "&VbCrlf
|
|
SQL = SQL&" SELECT r_position FROM R_Info "&VbCrlf
|
|
SQL = SQL&" WHERE flag='1' "&VbCrlf
|
|
SQL = SQL&" ) AA "&VbCrlf
|
|
SQL = SQL&" pivot "&VbCrlf
|
|
SQL = SQL&" ( "&VbCrlf
|
|
SQL = SQL&" count(r_position) for r_position in ([1],[2],[3],[4]) "&VbCrlf
|
|
SQL = SQL&" ) pvt "&VbCrlf
|
|
|
|
objdb.Open SQL, DBConn,3,1,1
|
|
set json = jsObject()
|
|
If not objdb.Eof Then
|
|
json("tCnt") = objdb("tcnt")
|
|
json("lCnt") = objdb("lCnt")
|
|
json("mCnt") = objdb("mCnt")
|
|
json("fCnt") = objdb("fCnt")
|
|
json("sCnt") = objdb("sCnt")
|
|
Else
|
|
json("tCnt") = "0"
|
|
json("lCnt") = "0"
|
|
json("mCnt") = "0"
|
|
json("fCnt") = "0"
|
|
json("sCnt") = "0"
|
|
End If
|
|
DBClose()
|
|
|
|
response.write toJson(json)
|
|
case "cnt"
|
|
DBConnect()
|
|
|
|
SQL = ""
|
|
SQL = SQL &" SELECT "&VbCrlf
|
|
SQL = SQL &" count(*) as tCnt, "&VbCrlf
|
|
SQL = SQL &" (select count(*) from exitpoll.dbo.R_info where Flag='1' and r_gender='1') mCnt, "&VbCrlf
|
|
SQL = SQL &" (select count(*) from exitpoll.dbo.R_info where Flag='1' and r_gender='2') wCnt "&VbCrlf
|
|
SQL = SQL &" FROM exitpoll.dbo.R_info where Flag='1' "&VbCrlf
|
|
Objdb.Open SQL,DBConn,3,1,1
|
|
'response.write sQL
|
|
|
|
If not objdb.Eof Then
|
|
set json = jsObject()
|
|
json("tCnt") = objdb("tCnt")
|
|
json("mCnt") = objdb("mCnt")
|
|
json("wCnt") = objdb("wCnt")
|
|
End If
|
|
DBClose()
|
|
|
|
response.write toJson(json)
|
|
|
|
case "RecruitDate"
|
|
DBConnect()
|
|
|
|
SQL = ""
|
|
SQL = SQL &" SELECT convert(varchar(10), Regdate, 20) Regdate, count(convert(varchar(10), Regdate, 20)) tcnt FROM exitpoll.dbo.R_info where Flag='1' "&VbCrlf
|
|
SQL = SQL &" group by convert(varchar(10), Regdate, 20) "&VbCrlf
|
|
Objdb.Open SQL,DBConn,3,1,1
|
|
|
|
If not objdb.eof Then
|
|
iCnt = 0
|
|
Redim json_arr1(objdb.recordCount-1)
|
|
while not objdb.eof
|
|
set allDate = jsObject()
|
|
allDate("Regdate") = objdb("Regdate")
|
|
allDate("tcnt") = objdb("tcnt")
|
|
|
|
set json_arr1(iCnt) = allDate
|
|
|
|
iCnt = iCnt + 1
|
|
objdb.movenext
|
|
wend
|
|
|
|
End If
|
|
|
|
DBClose()
|
|
|
|
DBConnect()
|
|
|
|
SQL = ""
|
|
SQL = SQL &" select Regdate, [1] man, [2] woman from "&VbCrlf
|
|
SQL = SQL &" ( "&VbCrlf
|
|
SQL = SQL &" select r_gender, convert(varchar(10), Regdate, 20) Regdate from exitpoll.dbo.R_info where Flag='1' "&VbCrlf
|
|
SQL = SQL &" ) as a "&VbCrlf
|
|
SQL = SQL &" pivot "&VbCrlf
|
|
SQL = SQL &" ( "&VbCrlf
|
|
SQL = SQL &" count(r_gender) for r_gender in ([1],[2]) "&VbCrlf
|
|
SQL = SQL &" ) pvt "&VbCrlf
|
|
Objdb.Open SQL,DBConn,3,1,1
|
|
|
|
If not objdb.eof Then
|
|
iCnt = 0
|
|
Redim json_arr2(objdb.recordCount-1)
|
|
while not objdb.eof
|
|
set gDate = jsObject()
|
|
gDate("Regdate") = objdb("Regdate")
|
|
gDate("man") = objdb("man")
|
|
gDate("woman") = objdb("woman")
|
|
|
|
set json_arr2(iCnt) = gDate
|
|
|
|
iCnt = iCnt + 1
|
|
objdb.movenext
|
|
wend
|
|
|
|
End If
|
|
|
|
DBClose()
|
|
|
|
set json = jsObject()
|
|
json("all") = json_arr1
|
|
json("gDate") = json_arr2
|
|
response.write toJson(json)
|
|
|
|
'response.write "[{""aa"":1}]"
|
|
|
|
case "RecruitGender"
|
|
|
|
DBConnect()
|
|
|
|
SQL = ""
|
|
SQL = SQL &" select *, case when r_gender = '1' then '남성' else '여성' end gender, cast(cnt as float)/cast(tcnt as float)*100 as per from "&VbCrlf
|
|
SQL = SQL &" ( "&VbCrlf
|
|
SQL = SQL &" select r_gender, count(r_gender) as cnt, (select count(*) from exitpoll.dbo.R_info where flag='1') as tcnt from exitpoll.dbo.R_info "&VbCrlf
|
|
SQL = SQL &" where Flag='1' "&VbCrlf
|
|
SQL = SQL &" group by r_gender "&VbCrlf
|
|
SQL = SQL &" ) a "&VbCrlf
|
|
Objdb.Open SQL,DBConn,3,1,1
|
|
|
|
If not objdb.eof Then
|
|
iCnt = 0
|
|
reDim json_arr1(objdb.recordCOunt-1)
|
|
|
|
while not objdb.eof
|
|
set gender = jsObject()
|
|
|
|
gender("name") = objdb("gender")
|
|
|
|
if objdb("gender") = "남성" Then
|
|
gender("drilldown") = "m"
|
|
else
|
|
gender("drilldown") = "w"
|
|
End If
|
|
gender("y") = Cdbl(Formatnumber(objdb("per"),1))
|
|
|
|
set json_arr1(iCnt) = gender
|
|
|
|
iCnt = iCnt + 1
|
|
objdb.movenext
|
|
wend
|
|
End if
|
|
DBClose()
|
|
|
|
DBConnect()
|
|
SQL = ""
|
|
SQL = SQL&" select r_gender, dbo.codeLabel('district', r_district, NULL) r_nm, r_district, count(r_gender) as cnt from exitpoll.dbo.R_info a "&VbCrlf
|
|
SQL = SQL&" where Flag='1' "&VbCrlf
|
|
SQL = SQL&" group by r_gender, r_district "&VbCrlf
|
|
SQL = SQL&" order by r_gender, r_district "&VbCrlf
|
|
Objdb.Open SQL,DBConn,3,1,1
|
|
|
|
If not objdb.eof Then
|
|
iCnt = 0
|
|
reDim json_arr2(objdb.recordCOunt-1)
|
|
while not objdb.eof
|
|
set district = jsObject()
|
|
district("gender") = objdb("r_gender")
|
|
district("district") = objdb("r_nm")
|
|
district("cnt") = objdb("cnt")
|
|
set json_arr2(iCnt) = district
|
|
iCnt = iCnt+1
|
|
objdb.movenext
|
|
wend
|
|
End If
|
|
|
|
DBClose()
|
|
|
|
set json = jsObject()
|
|
json("gender") = json_arr1
|
|
json("district") = json_arr2
|
|
response.write toJson(json)
|
|
|
|
|
|
End Select
|
|
|
|
%> |