select top 1 a.*,b.CheckName,b.Tel,(select datediff(d,getdate(),c.Coupon_End)<0) as isExpired
from CouponInfo a
inner join OrderInfo b on a.OrderNum=b.OrderNum
inner join Products c on a.ProductID=c.ProductID
where CouponCode=@CouponCode错误:'<' 附近有语法错误。
,(select datediff(d,getdate(),c.Coupon_End)<0) as isExpired 这样写不对,要如何写?
from CouponInfo a
inner join OrderInfo b on a.OrderNum=b.OrderNum
inner join Products c on a.ProductID=c.ProductID
where CouponCode=@CouponCode
from CouponInfo a
inner join OrderInfo b on a.OrderNum=b.OrderNum
inner join Products c on a.ProductID=c.ProductID
where CouponCode=@CouponCode无须那个select
datediff(d,getdate(),c.Coupon_End)<0 as isExpired
(datediff(d,getdate(),c.Coupon_End)<0) as isExpired
都错,我晕死·!
CASE WHEN datediff(d,getdate(),c.Coupon_End)<0 THEN '过期'
WHEN datediff(d,getdate(),c.Coupon_End)>0 THEN '没过期' end
as isExpired
from CouponInfo a
inner join OrderInfo b on a.OrderNum=b.OrderNum
inner join Products c on a.ProductID=c.ProductID
where CouponCode=@CouponCode