SQL 질문과 답변 게시판
DB : Mssql 2005
현재와 같은 Mssql 쿼리문을 Oracle 10g.2 버전으로 변경을 해야 합니다.
다른부분은 문제가 없는것같은데요
★요부분★ 이라고 주석처리되어있는 부분에서 에러가 납니다.
조인문의 조건절에서 그룹바이된 조회문을 사용할수 없는것 같은데요.
어떻식으로 쿼리를 바꿔야 정상적으로 쿼리문이 실행되는지 알고 싶습니다.
고수님들의 도움이 필요해요.
이왕이면 쿼리문 수정보다는 개념을 정확히 알려주셨으면 좋겠습니다.
이런 쿼리문들이 생각보다 많아서요...
고수님들 도와주세용~~
select
a.prno, a.prsubno, a.bucode, u.bu_name, a.cmb_ref_request
, a.itemcode, a.qty, a.cmb_supply, a.etdate, a.podate, a.chk_rush
, a.cmb_reason, a.remark, a.mdate
, a.mono, a.mosubno, a.mosubno2, a.tBuyType
, i.custcode, i.itemcode1, i.itemname, i.spec
, n.subname as unit
, n1.subname as unit2
, c.cu_sangho
, c1.gMoney, c1.cmb_price
, c2.lotsize, c2.minQty, c2.conversionfactor
, p1.unitprice, p2.unitprice as stdprice
from t_pm_requestsub a
left outer join t_mi_item i on a.gubun=i.gubun and a.itemcode=i.itemcode
left outer join (select gubun, typecode, subcode, subname, subname as unit from t_mi_typesub) n
on i.gubun=n.gubun and i.cmb_unit=n.subcode And n.typecode='MI001'
left outer join a_busor u on a.gubun=u.bu_gubun and a.bucode=u.bu_code
left outer join c_cust c on i.gubun=c.cu_gubun and i.custcode=c.cu_code
left outer join t_mi_cust c1 on i.gubun=c1.gubun and i.custcode=c1.custcode
left outer join t_mi_item_custinfo c2 on a.gubun=c2.gubun and i.custcode=c2.custcode and a.itemcode=c2.itemcode
left outer join (select gubun, typecode, subcode, subname, subname as unit from t_mi_typesub) n1
on c2.gubun=n1.gubun and c2.cmb_unit=n1.subcode And n1.typecode='MI001'
★요부분★
left outer join t_mi_price_buycust p1 on a.gubun = p1.gubun
and a.itemcode = p1.itemcode
and i.custcode =p1.custcode
and c1.gMoney = p1.gMoney
and p1.condate =(select max(condate)
from t_mi_price_buycust
where gubun=a.gubun
and itemcode= a.itemcode
and custcode=i.custcode
and gMoney = c1.gMoney
and condate <=a.etdate)
★요부분★
left outer join t_mi_price_buystd p2 on a.gubun=p2.gubun
and a.itemcode= p2.itemcode
and c1.gMoney = p2.gMoney
and p2.condate =(select max(condate)
from t_mi_price_buystd
where gubun=a.gubun
and itemcode= a.itemcode
and gMoney = c1.gMoney
and condate <=a.etdate)
where a.gubun ='01'
and a.prno = '201008-0002'
and a.prsubno = '001'"


아.. 길다...
테이블 description 있으면 어찌 테스트 해볼 수 있으련만.. 눈으로만 보고 틀린거 찾기가 만만치 않군요.. ㅠㅠ