如果我在“2013-10-29”上搜索,我必须显示 Visit_Date 列的最大日期,然后记录显示这些客户的日期为“2013-10-29”,但在列中我必须显示客户的最大日期
问问题
66 次
4 回答
2
这个 ...
SELECT
P_Master.PID,
Visit_Date,
(SELECT MAX(Visit_Date) FROM P_Visit v WHERE v.PID = p_Master.PID) as MaxVisit
FROM P_Master
LEFT JOIN P_VISIT
ON P_Master.PID=P_VISIT.PID
WHERE CAST(CONVERT(varchar(10), Visit_Date, 101) AS datetime)='2013-10-29'
... 添加最近访问日期的列
于 2013-10-30T06:39:05.520 回答
1
SELECT
P_Master.PID,
Visit_Date FROM P_Master
LEFT JOIN P_VISIT
on Visit_Date=(SELECT MAX(Visit_Date) FROM [dbo].[P_Visit] WHERE P_Master.PID=P_VISIT.PID )
于 2013-10-30T06:33:54.533 回答
1
尝试这个 :
SELECT
P_Master.PID,
(SELECT MAX(Visit_Date) FROM P_Master
LEFT JOIN P_VISIT ON P_Master.PID=P_VISIT.PID) AS VISIT_DATE
FROM P_Master
LEFT JOIN P_VISIT
ON P_Master.PID=P_VISIT.PID
WHERE CAST(CONVERT(varchar(10), Visit_Date, 101) AS datetime)='2013-10-29'
于 2013-10-30T06:41:22.550 回答
-1
SELECT
P_Master.PID,
MAX(Visit_Date) FROM P_Master
LEFT JOIN P_VISIT
ON P_Master.PID=P_VISIT.PID
将为您提供每位访客的最近一次访问
于 2013-10-30T06:29:22.037 回答