我有2张桌子- “俱乐部会员”表包含3个字段,例如:
var firstString = "<h3>askhaks</h3><h3>1212</h3><h1 style='color:red;text-decoration:underline;'><a href=''><span id='123'><i class='fa fa-inr'></i></span> Hello! Admin</span></a></h1><p>This is the content of page 'String Replace in Javascript'</p><h1>First</h1><span><h1>Second</h1>Thank You for visiting this page</span><h1>Third</h1>";
const doc = new DOMParser().parseFromString(firstString, 'text/html');
const h1Text = doc.querySelector('h1').textContent.trim();
console.log(firstString.replace(h1Text, 'foo bar new string'));
“月份列表”表,其中包含1个字段:
"Member_ID", "Date_Of_Birth"
1 13/4/1980
2 20/4/1990
3 30/12/1970
4 20/11/1960
我希望生成一个查询,显示 月份,Number_Of_Birthdays
例如:
"Month"
4-2017
5-2017
...
11-2017
12-2017
...
4-2018
...
11-2018
12-2018
如何在访问中做到这一点?
谢谢
答案 0 :(得分:1)
使用inner join
和聚合函数count
在编辑问题时,请尝试以下查询,请记住此处的日期格式是主要问题,因此请保持相同的格式
select ML.Month,Number_Of_Birthdays_Of_Club_Memebers from
(
select format(Member_Date_Of_Birth,"mm-yyyy") as month_number,count(Member_ID) as Number_Of_Birthdays_Of_Club_Memebers
from club_members
group by format(Member_Date_Of_Birth,"mm-yyyy")
)as T1
inner join months_list as ML
T1.month_number=ML.Month
答案 1 :(得分:1)
如果要按加入日期计算成员数,请使用此选项。
Select b.Month_Date, Count(a.*) as Total_Members
From Club_Members as a INNER Join Month_List as b
ON a.Member_Join_Date=b.Month_Date
Group BY B.month_Date
答案 2 :(得分:1)
尝试一下:
SELECT Month_Date, sum(MemberCount)
FROM (
SELECT c.Member_ID, c.Member_Join_Date, m.Month_Date,CASE WHEN c.Member_Join_Date < m.Month_Date THEN 1 ELSE 0 END MemberCount
FROM club_members c, months_list m
) s
GROUP BY Month_Date