これは私の質問です
Create FUNCTION [dbo].[CountUses](@couponid INT)
RETURNS INT
AS
BEGIN
RETURN
(
SELECT c.Id,
c.Name,
c.CreateDate,
Count(cu.id) NofUses
FROM Coupon as c
JOIN CouponUse as cu
ON c.id = cu.couponid
GROUP BY c.Id,
c.Name,
c.CreateDate
)
END
問題はどこOnly one expression can be specified in the select list when the subquery is not introduced with EXISTS.
にあるのですか?
主な回答とは別に、クエリの最適化についてコメントをいただければ幸いです...