안녕하세요 해당 쿼리를 실행해서 29주차 ~ 31주차의 값 3개를 구하고 싶은데
29주차 ~ 31주차에 3주차가 마지막에 붙어서 나옵니다...
해당 기간만의 값만 나오게 어떻게 하나요...? 도움 요청드립니다ㅠㅠ
SELECT
CONVERT(VARCHAR(8),DATEPART(WEEK,B.PlanDate))+'주차' AS 날짜,
SUM(A.GPDeaQty) / SUM(B.Qty) * 100 AS 육계GP
FROM [DCH].[dbo].[dch_TPDCarDefectiveBodyReq] AS A WITH(NOLOCK)
LEFT OUTER JOIN [DCH].[dbo].[dch_TFALiveChickenInDriverReg] AS B WITH(NOLOCK)
ON A.CompanySeq = B.CompanySeq
AND A.ChickenInSeq = B.ChickenInSeq
AND B.UMChickenKind = 2000010001
WHERE A.CompanySeq = 2
AND CONVERT(VARCHAR(8),DATEPART(WEEK,B.PlanDate)) BETWEEN '29' AND '31'
GROUP BY
CONVERT(VARCHAR(8),DATEPART(WEEK,B.PlanDate))+'주차'
ORDER BY
CONVERT(VARCHAR(8),DATEPART(WEEK,B.PlanDate))+'주차'