我写了以下查询
SELECT
us.Id as Id, us.Name as Name,
SUM(CASE WHEN c.isPublish = 0 THEN 1 ELSE 0 END) AS PendingCoupons,
SUM(CASE WHEN c.isPublish = 1 and convert(date,c.PublishedDate,101) >= convert(date, GETDATE(), 101) THEN 1 ELSE 0 END) AS ApprovedCouponsToday,
SUM(CASE WHEN c.isPublish = 0 and convert(date,c. CreateDate, 101) = convert(date, GETDATE(), 101) THEN 1 ELSE 0 END) AS PendingCouponsToday,
SUM(CASE WHEN c.isPublish = 1 THEN 1 ELSE 0 END) AS ApprovedCoupons,
SUM(CASE WHEN c.isPublish = 1 and c.Userid = us.Id and convert(date, c.PublishedDate, 101) >= convert(date, GETDATE(), 101) THEN 1 ELSE 0 END) AS ApprovedByUserToday,
SUM(CASE WHEN c.isPublish = 1 and c.Userid = us.Id THEN 1 ELSE 0 END) AS ApprovedByUser,
SUM(CASE WHEN c.ReviewVerify = 1 and convert(date, c.PublishedDate, 101) >= convert(date, GETDATE(), 101) THEN 1 ELSE 0 END) AS ProcessToday,
COUNT(*) AS Total
FROM
Users AS us
LEFT JOIN
Coupon c ON Userid = us.Id
GROUP BY
us.Name , us.Id
我有以下两张桌子
在运行上面的查询之后,结果总是这样
这个查询是否有任何错误,因为它总是返回我计数“0”,我每个用户都有近 100 张优惠券但它没有显示