如何Max(OD.CYCLE_END_DATE)
从下面的查询中获取其他列?
SELECT C.MASTER_CUSTOMER_ID
,C.USR_SPE_Membership_Status
,OD.PRODUCT_CODE
,OD.CYCLE_BEGIN_DATE
,OD.CYCLE_END_DATE
,LINE_STATUS_CODE
FROM CUSTOMER C
LEFT OUTER JOIN ORDER_DETAIL OD
ON C.MASTER_CUSTOMER_ID = OD.SHIP_MASTER_CUSTOMER_ID
AND C.SUB_CUSTOMER_ID = OD.SHIP_SUB_CUSTOMER_ID
AND OD.PRODUCT_CODE in ('PROFESSIONAL','LIFE','STUDENT','STAFF')
--AND OD.CYCLE_BEGIN_DATE <= GETDATE()
AND OD.CYCLE_END_DATE >= GETDATE()
where C.MASTER_CUSTOMER_ID= '3420065'
结果
MASTER_CUSTOMER_ID USR_SPE_Membership_Status PRODUCT_CODE CYCLE_BEGIN_DATE CYCLE_END_DATE LINE_STATUS_CODE
3420065 Paid Member LIFE 2013-01-01 2013-12-31 A
3420065 Paid Member LIFE 2014-01-01 2014-12-31 A
我需要2014-12-31
行。