当 COUNT() < 2 但由于某种原因我的语法不正确时,我试图从“years”一词中删除“s”:
错误: 关键字“IF”附近的语法不正确。关键字“convert”附近的语法不正确。
stuff(
(
select ',' + Related_name + ' (' + (select
IF COUNT(begin_date) > 1 BEGIN convert(varchar(10), COUNT(begin_date)) + ' years)' END
ELSE BEGIN convert(varchar(10), COUNT(begin_date)) + ' year)'
from cus_relationship subInnerR
where subInnerR.master_customer_id = c.master_customer_id
and subInnerR.related_master_customer_id = innerR.related_master_customer_id
and subInnerR.relationship_type = 'ADVSPR'
and subInnerR.relationship_code = 'CLUB'
and subInnerR.reciprocal_code = 'FACADV')
from cus_relationship innerR
where [...]