我有member
表member_Id
一个mmship
表,其中包含mmshipstart date
和member_Id
以及mshipstatus_Id
另一个包含mshipstatustype
列和mshipstatus_Id
mshipstatus_name
我的mshipstatus_name
行值为prospective
......
如何获得members(count)
mshipstatusname
每月prospective
的数量mmshipstart date
我可以从{{1}}开始计算。
任何人都可以帮助我......
我是新手加入任何人都会帮助......
答案 0 :(得分:0)
以下应该可以解决问题:
SELECT COUNT(*)
FROM member inner join mmship
ON member.member_Id = mmship.member_Id
INNER JOIN mshipstatus
ON mshipstatus.mshipstatus_Id = mmship.mshipstatus_Id
WHERE mshipstatus.mshipstatusname = 'prospective'
AND MONTH(mmship.mmshipstart_date) = MONTH(GETDATE())
(您可以使用其他日期更改getdate())。
答案 1 :(得分:0)
select count(*) as prospective from mshipstatustype t1 join mmship t2 where
t1.mshipstatus_id=t2.mshipstatus_id and t2.mshipstatus_name="prospective" group by
year(mmshipstart_date), month(mmshipstart_date)
做你想做的事吗?