0
데이터 테이블에서 가장 최근 가격을 얻으려고합니다. 나는 "10,525 5.00 2014년 7월 6일"의 결과를 얻을 수 있도록 조인 사용하려고SQL Left Join Subquery Issue
Part Price Date
----- ----- --------
10525 .25 1/1/2010
10525 5.00 7/6/2014
10526 4.25 7/1/2014
, 그러나 그것은 나에게이 오류 제공 : 데이터는 같이 나올 것
을The column prefix 'orderdtl' does not match with a table name or alias name used in teh query. Statement(s) could not be prepared."
가입을 취소하면 정상적으로 작동합니다. 내가 어디로 잘못 가고 있니?
SELECT orderdtl.partnum, orderdtl.docunitprice, orderhed.orderdate
FROM mfgsys80.dbo.orderdtl AS orderdtl, mfgsys80.dbo.orderhed AS orderhed
INNER JOIN(
SELECT orderdtl.partnum, MAX(orderhed.orderdate) AS 'maxDate'
FROM mfgsys80.dbo.orderdtl AS orderdtl, mfgsys80.dbo.orderhed AS orderhed
GROUP BY orderdtl.partnum
) AS Temp
ON orderdtl.partnum = Temp.partnum AND orderhed.orderdate = Temp.maxDate
WHERE orderdtl.ordernum = orderhed.ordernum AND ((orderdtl.custnum=74))
ORDER BY orderdtl.partnum
당신의 도움에 감사드립니다! 내 SQL은 꽤 녹슬었지만 당신이 한 것은 내가 그것을 보았을 때 의미가있다. – Error