DECLARE @p_frdt varchar(08) /* 작업일자(from) */
DECLARE @p_todt varchar(08) /* 작업일자(to) */
DECLARE @p_itemcode varchar(20) /* 품목코드 */
DECLARE @p_workcode varchar(10) /* 일련번호 */
set @p_frdt ='20130103' /* 작업일자(from) */
set @p_todt ='20130103' /* 작업일자(to) */
select b.f_workdate 검사일자 ,
--b.f_worktime 검사시간 ,
CONVERT(CHAR(8), b.f_worktime, 8) 검사시간 ,
a.f_itemcode 품목코드 ,
a.f_inspdetail 검사항목 ,
a.f_standard 규격,
case when a.f_singlechk = '2' then '' else convert(numeric(20,6),a.f_max) end 상한,
case when a.f_singlechk = '1' then '' else convert(numeric(20,6),a.f_min) end 하한,
c.f_measure 측정값 ,
b.f_workman 작업자 ,
case when b.f_wrongreport='0' then '합격' else '규격이탈' end 판정 ,
IsNULL(d.f_contents, '' ) 원인 ,
IsNULL(d.f_returnco, '' ) 조치 ,
--case when d.f_remark=NULL then IsNULL(d.f_remark,'') else replace(replace(d.f_remark, char(13), ''), char(10), '') end 비고
replace(replace(IsNULL(d.f_remark,''), char(13), ''), char(10), '') 비고
from
qcd34_tbl a ,
qwk03a_tbl b ,
qwk04a_tbl c
LEFT OUTER JOIN qwkwrongreportgun d
ON c.f_measno = d.f_measno
where a.f_itemcode = b.f_itemcode
--and b.f_workdate between '20130103' and '20130103'
and b.f_workdate between @p_frdt and @p_todt
and a.f_serialno = b.f_serialno
and c.f_measno = b.f_measno
and b.f_inspitem = '01'
--and b.f_worktime ='113853'
and a.f_itemcode like 'DA97-02198B'
order by b.f_workdate, b.f_worktime
------------
위에서 검사시간 데이터가 CHAR(6) 형태로 받아오는데
이게 초단위로 기록된 데이터라 시분초로 변환이 필요합니다
그래서 위와같이 처리했는데
":" 요게 빠져서 나오네요
20130103 113853 DA97-02198B 외경1 194.60 195.100000 194.100000 194.81 ㅇㅇ 합격
어떻게하면 나올까요?
SUBSTRING으로 2자리씩 잘라서 :랑 연결 하시는게..