MS-SQL쿼리문
SELECT A.order_no, A.input_order_id, A.weighing_no, convert(char(10), min(A.weighing_start_time), 120) as weighing_start_time
,max(B.item_nm) as item_nm, max(A.lot_no) as lot_no, C.process_cd, D.process_nm
FROM weighing A
INNER JOIN v_item_standard B ON A.item_cd = B.item_cd
INNER JOIN input_order_process C ON A.order_no = C.order_no AND A.input_order_id = C.input_order_id
AND A.weighing_no = C.weighing_no
INNER JOIN process D ON C.process_cd = D.process_cd
WHERE weighing_start_time BETWEEN convert(datetime, @start_date) and convert(datetime, @end_date) + 0.99999
AND (isnull(A.item_cd, '') like @item_cd + '%' OR isnull(B.item_nm, '') like @item_cd + '%')
AND A.lot_no like @lot_no + '%'
GROUP BY A.order_no, A.input_order_id, A.weighing_no, C.process_cd, D.process_nm
ORDER BY A.weighing_start_time
이것을 컨버젼 해서
SELECT A.order_no,
A.input_order_id,
A.weighing_no,
TO_CHAR(MIN(A.weighing_start_time), 'YYYY-MM-DD') weighing_start_time,
MAX(B.item_nm) item_nm,
MAX(A.lot_no) lot_no,
C.process_cd,
D.process_nm
FROM weighing A
JOIN v_item_standard B
ON A.item_cd = B.item_cd
JOIN input_order_process C
ON A.order_no = C.order_no
AND A.input_order_id = C.input_order_id
AND A.weighing_no = C.weighing_no
JOIN process D
ON C.process_cd = D.process_cd
WHERE weighing_start_time BETWEEN CAST('2011-06-28' AS DATE) AND CAST('2011-07-28' AS DATE) + 0.99999
AND ( NVL(A.item_cd, ' ') LIKE '' || '%'
OR NVL(B.item_nm, ' ') LIKE '' || '%' )
AND A.lot_no LIKE '' || '%'
GROUP BY A.order_no,A.input_order_id,A.weighing_no,C.process_cd,D.process_nm
ORDER BY A.weighing_start_time;
이렇게 바꾸니
group by 표현식이 아니라고 오류가 뜹니다..
왜그런지 이해가 안가네요.
MAX와 MIN으로 묶이 부분 빼고 나머지도 MAX와 MIN으로 묶으니
값은 한개밖에 안나오고;; 어찌해야될지 모르겟습니다.
도와주세요 ㅠㅠ