34,588
社区成员
发帖
与我相关
我的任务
分享
DECLARE @date datetime
DECLARE @diff_date datetime
DECLARE @current_date datetime
set @current_date = '2012-12-10'
set @date =
(
SELECT top 1 时间
FROM BuyInformation
ORDER BY 时间 DESC
)
set @diff_date = @current_date - @date
SELECT * FROM USERINFO WHERE userid IN (SELECT userid FROM BuyInformation WHERE DATEDIFF(day, 时间, GETDATE()) > 30)
DECLARE @date datetime
DECLARE @current_date datetime
set @current_date = '2012-12-10'
set @date =
(
SELECT top 1 时间 as date
FROM BuyInformation
WHERE 用户编号 = '000100010001'
ORDER BY 时间 DESC
)
--if ( DATEDIFF(day, @date, @current_date > 30 )
-- BEGIN
SELECT * FROM USERINFO WHERE DATEDIFF(day, @date, @current_date > 30--用户编号 = '000010001001'
--END
DECLARE @date datetime
DECLARE @current_date datetime
set @current_date = '2012-12-10'
set @date =
(
SELECT top 1 时间 as date
FROM BuyInformation
WHERE 用户编号 = '000100010001'
ORDER BY 时间 DESC
)
if ( DATEDIFF(day, @date, @current_date > 30 )
BEGIN
SELECT * FROM USERINFO WHERE 用户编号 = '000010001001'
END