这个sql语该如何写???

shengyuan5278 2003-10-17 05:05:23
一个表,三个字段,(客户,时间,金额),现要统计某一客户,在指定时间段内,金额所占所有金额的比率,急啊,请指教!
...全文
34 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
dickeybird888 2003-10-17
  • 打赏
  • 举报
回复
哈哈,楼上已经说了,我没有什么说的了,接分把
gx 2003-10-17
  • 打赏
  • 举报
回复
select case when select Sum(金额) from table is 0 then null else sum(金额)/(select Sum(金额) from table) from table group by 客户 where 时间 >=s1 and 时间<s2 and
客户 = kh end
gx 2003-10-17
  • 打赏
  • 举报
回复
select case when select Sum(金额) from table is 0 then null else sum(金额)/(select Sum(金额) from table) from table where 时间 >=s1 and 时间<s2 and
客户 = kh end
chenkandy 2003-10-17
  • 打赏
  • 举报
回复
select (b1/a1)*100 as Get_Data
from (select sum(金额) as a1 from tabel) a,
(select sum(金额) as b1 from tabel where customer_no=some_no and
table.time>=some_time1 and table.time<=some_time2) b

用兩個sql語句當能tabel, 把選擇出的值相除就可以了
給分了.:)
angle097113 2003-10-17
  • 打赏
  • 举报
回复
select Sum(金额) from table) 就是这句话和楼上的不一样的
angle097113 2003-10-17
  • 打赏
  • 举报
回复
select 金额/(select Sum(金额) from table) from table where 时间 >=s1 and 时间<s2 and
客户 = kh
cqzyf 2003-10-17
  • 打赏
  • 举报
回复
select 金额/(select 金额 from table) from table where 时间 >=s1 and 时间<s2 and
客户 = kh

5,379

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧