본문 바로가기

공책

SQL 값 옆으로 뿌리기.

반응형

<%

 
 sql = " select "
 sql = sql & "  Company_Kind, Product_Code,Product_Name,"
 sql = sql & "               max(case when Product_Month = '1' then Material_Price else '' end)    as [1재료비],"
 sql = sql & "               max(case when Product_Month = '1' then cr else '' end)                as [1CR],"
 sql = sql & "               max(case when Product_Month = '1' then ExchangeRate_gap else '' end) as [1환차],"
 sql = sql & "               max(case when Product_Month = '1' then Product_Output else '' end)  as [1생산량],"
 sql = sql & "               max(case when Product_Month = '1' then CR_percent else '' end)    as [1CR율],"

 sql = sql & "               max(case when Product_Month = '2' then Material_Price else '' end)  as [2재료비],"
 sql = sql & "               max(case when Product_Month = '2' then cr else '' end)         as [2CR],"
 sql = sql & "               max(case when Product_Month = '2' then ExchangeRate_gap else '' end)  as [2환차],"
 sql = sql & "               max(case when Product_Month = '2' then Product_Output else '' end)  as [2생산량],"
 sql = sql & "               max(case when Product_Month = '2' then CR_percent else '' end)      as [2CR율],"

 sql = sql & "               max(case when Product_Month = '3' then Material_Price else '' end)  as [3재료비],"
 sql = sql & "               max(case when Product_Month = '3' then cr else '' end)             as [3CR],"
 sql = sql & "               max(case when Product_Month = '3' then ExchangeRate_gap else '' end) as [3환차],"
 sql = sql & "               max(case when Product_Month = '3' then Product_Output else '' end)  as [3생산량],"
 sql = sql & "               max(case when Product_Month = '3' then CR_percent else '' end)      as [3CR율],"

 sql = sql & "               max(case when Product_Month = '4' then Material_Price else '' end)  as [4재료비],"
 sql = sql & "               max(case when Product_Month = '4' then cr else '' end)         as [4CR],"
 sql = sql & "               max(case when Product_Month = '4' then ExchangeRate_gap else '' end) as [4환차],"
 sql = sql & "               max(case when Product_Month = '4' then Product_Output else '' end)  as [4생산량],"
 sql = sql & "               max(case when Product_Month = '4' then CR_percent else '' end)     as [4CR율],"

 sql = sql & "               max(case when Product_Month = '5' then Material_Price else '' end)  as [5재료비],"
 sql = sql & "               max(case when Product_Month = '5' then cr else '' end)         as [5CR],"
 sql = sql & "               max(case when Product_Month = '5' then ExchangeRate_gap else '' end)  as [5환차],"
 sql = sql & "               max(case when Product_Month = '5' then Product_Output else '' end)    as [5생산량],"
 sql = sql & "               max(case when Product_Month = '5' then CR_percent else '' end)     as [5CR율],"

 sql = sql & "               max(case when Product_Month = '6' then Material_Price else '' end)    as [6재료비],"
 sql = sql & "               max(case when Product_Month = '6' then cr else '' end)         as [6CR],"
 sql = sql & "               max(case when Product_Month = '6' then ExchangeRate_gap else '' end)  as [6환차],"
 sql = sql & "               max(case when Product_Month = '6' then Product_Output else '' end)    as [6생산량],"
 sql = sql & "               max(case when Product_Month = '6' then CR_percent else '' end)     as [6CR율],"

 sql = sql & "               max(case when Product_Month = '7' then Material_Price else '' end)   as [7재료비],"
 sql = sql & "               max(case when Product_Month = '7' then cr else '' end)         as [7CR],"
 sql = sql & "               max(case when Product_Month = '7' then ExchangeRate_gap else '' end)  as [7환차],"
 sql = sql & "               max(case when Product_Month = '7' then Product_Output else '' end)   as [7생산량],"
 sql = sql & "               max(case when Product_Month = '7' then CR_percent else '' end)     as [7CR율],"

 sql = sql & "               max(case when Product_Month = '7' then Material_Price else '' end)   as [8재료비],"
 sql = sql & "               max(case when Product_Month = '7' then cr else '' end)         as [8CR],"
 sql = sql & "               max(case when Product_Month = '7' then ExchangeRate_gap else '' end)  as [8환차],"
 sql = sql & "               max(case when Product_Month = '7' then Product_Output else '' end)   as [8생산량],"
 sql = sql & "               max(case when Product_Month = '7' then CR_percent else '' end)     as [8CR율],"

 sql = sql & "               max(case when Product_Month = '8' then Material_Price else '' end)   as [9재료비],"
 sql = sql & "               max(case when Product_Month = '8' then cr else '' end)         as [9CR],"
 sql = sql & "               max(case when Product_Month = '8' then ExchangeRate_gap else '' end)  as [9환차],"
 sql = sql & "               max(case when Product_Month = '8' then Product_Output else '' end)   as [9생산량],"
 sql = sql & "               max(case when Product_Month = '8' then CR_percent else '' end)     as [9CR율],"

 sql = sql & "               max(case when Product_Month = '9' then Material_Price else '' end)   as [9재료비],"
 sql = sql & "               max(case when Product_Month = '9' then cr else '' end)         as [9CR],"
 sql = sql & "               max(case when Product_Month = '9' then ExchangeRate_gap else '' end)  as [9환차],"
 sql = sql & "               max(case when Product_Month = '9' then Product_Output else '' end)   as [9생산량],"
 sql = sql & "               max(case when Product_Month = '9' then CR_percent else '' end)     as [9CR율],"

 sql = sql & "               max(case when Product_Month = '10' then Material_Price else '' end)  as [10재료비],"
 sql = sql & "               max(case when Product_Month = '10' then cr else '' end)        as [10CR],"
 sql = sql & "               max(case when Product_Month = '10' then ExchangeRate_gap else '' end) as [10환차],"
 sql = sql & "               max(case when Product_Month = '10' then Product_Output else '' end)   as [10생산량],"
 sql = sql & "               max(case when Product_Month = '10' then CR_percent else '' end)    as [10CR율],"

 sql = sql & "               max(case when Product_Month = '11' then Material_Price else '' end)   as [11재료비],"
 sql = sql & "               max(case when Product_Month = '11' then cr else '' end)        as [11CR],"
 sql = sql & "               max(case when Product_Month = '11' then ExchangeRate_gap else '' end) as [11환차],"
 sql = sql & "               max(case when Product_Month = '11' then Product_Output else '' end)   as [11생산량],"
 sql = sql & "               max(case when Product_Month = '11' then CR_percent else '' end)    as [11CR율],"

 sql = sql & "               max(case when Product_Month = '12' then Material_Price else '' end)  as [12재료비],"
 sql = sql & "               max(case when Product_Month = '12' then cr else '' end)        as [12CR],"
 sql = sql & "               max(case when Product_Month = '12' then ExchangeRate_gap else '' end) as [12환차],"
 sql = sql & "               max(case when Product_Month = '12' then Product_Output else '' end)   as [12생산량],"
 sql = sql & "               max(case when Product_Month = '12' then CR_percent else '' end)     as [12CR율]"

 sql = sql & " from Price_Reduction"
 sql = sql & " group by Product_Code, Company_Kind,Product_Name"
 
 set Rs = Server.CreateObject("ADODB.RecordSet")
 set Rs = dbs.Execute (sql)
 
 
%>

반응형

'공책' 카테고리의 다른 글

원가  (0) 2012.02.07
캐드 뷰어 설치  (0) 2010.11.11
덱스트 업로드 OK 페이지  (0) 2010.11.05
NTFS.SYS - xp 복구  (0) 2010.10.28
IP 배치 파일 만들기.  (0) 2010.06.30