在foxpro中计数有条件
我有一个表,
id name date
1 a 08/09/2003
2 b 02/03/2003
3 c 10/08/2004
4 c 25/08/2007
5 a 01/01/2008
我想要计数数据库。 下表及结果如下:
2003 = 2
2004 = 1
2007 = 0 because c has in 2004-year
2008 = 0 because a has in 2003-year
i have a table follow
id name date
1 a 08/09/2003
2 b 02/03/2003
3 c 10/08/2004
4 c 25/08/2007
5 a 01/01/2008
i want count database.
with table below with result follow:
2003 = 2
2004 = 1
2007 = 0 because c has in 2004-year
2008 = 0 because a has in 2003-year
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
首先,获取名称及其出现的最早年份:
然后获取该年份内的计数:
First, get the name and the earliest year it appears in:
Then get the count from within that year:
我可能正在解决一个不同的问题,但此代码给出了每年未出现在前几年的名称的计数:
I may be solving a different problem but this code gives the count in each year for names that have not appeared in previous years:
*/ 首先,在他们进行交易的第一年按姓名计算
*/ 对于...除了此人拥有的总交易量之外
*/ 年度.. 例如:“a”和“c”人的两个重叠
*/ 现在您已经根据每个人的第一年及其总数得出了总计
*/ 不管年份的条目,获取年份和 HAVE 的总数
*/ 给定年份的条目....然后对所有原始年份的可能性进行联合
*/ 不在 C_ByNameTotals 结果集中。 (因此是 2007 年和 2008 年)
*/ First, get on a per name basis the first year they have a transaction
*/ for... in addition to the total transactions this person has regardless
*/ of the year.. ex: your two overlap of "a" and "c" persons
*/ Now that you have totals based on the first year per person with their total
*/ entries regardless of the year, get the year and sum of totals that HAVE
*/ entries for a given year.... THEN UNION for all original year possibilities
*/ that were NOT IN the C_ByNameTotals result set. (hence your 2007 and 2008)