一个可能有点难度的SQL语句,请大人赐教。。。。

[复制链接]
查看11 | 回复3 | 2011-4-9 20:20:26 | 显示全部楼层 |阅读模式
已知统计表 [Statis]
有字段 [Time],[Accent],[Modulus],[Result]
查询2011年4月1号至2011年4月30号里
每个Accent的Result=True的数量,和 Result=True的数量 与Modulus 的乘积
补充说明下
查询结果我刚刚说错了
应该是
查询2011年4月1号至2011年4月30号里
每个Accent的Result=True的数量,和 Result=True时 同一与Modulus 的总和
例如上图 的结果的话
应该是
Accent Count
0010010647
0010010790
……

回复

使用道具 举报

千问 | 2011-4-9 20:20:26 | 显示全部楼层
如果每个accent的result=1时的Modulus都相同的话,可以这么写:Select a.accent,b.anum,b.anum*a.modulus as product from (Select distinct( Accent), modulus From Statis where result=1) as a inner join(Select Accent, count(*) as anum From StatisWhere time between '2011-4-1' and '2011-4-30' and result=1group by accent) as b on a.accent=b.accent
回复

使用道具 举报

千问 | 2011-4-9 20:20:26 | 显示全部楼层
以下语句可以得出每个Accent的Result=True的数量Select Accent, count(*)From StatisWhere time between '2011-4-1' and '2011-4-30'group by accent
having accent=1题目本身有问题, 对于每个Accent在
回复

使用道具 举报

千问 | 2011-4-9 20:20:26 | 显示全部楼层
你是什么意思没看懂?你给出的图又是什么意思?
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行