select f1,f2,f3,f2/f3 as 总数 from ((select country as f1,sum(quantity) as f2 from new group by country)as A cross join (select sum(quantity) as f3 from new ) as B) 结果是查询出来了,但是总数项全部为了 为什么呢?
试试: select f1,f2,f3,CDbl(f2)/CDbl(f3) as 总数 from ((select country as f1,sum(quantity) as f2 from new group by country)as A cross join (select sum(quantity) as f3 from new ) as B)
select f1, f2, f3, (f2+0.000)/f3 as 总数 from ((select country as f1,sum(quantity) as f2 from new group by country) as A cross join (select sum(quantity) as f3 from new ) as B)
select f1,f2,f3,CAST(f2 AS FLOAT)/CAST(f3 AS FLOAT) as 总数 from ( ((select country as f1,sum(quantity) as f2 from new group by country)as A cross join (select sum(quantity) as f3 from new ) as B) ) WHERE F3<>0
try:select f1,f2,f3, cast(f2 as money) / cast(f3 as money) as 总数 from (select country as f1, sum(quantity) as f2 from new group by country) A cross join (select sum(quantity) as f3 from new ) B
他的要求是在这样的: 一个表中有三个字段为saler country quantity 我想按country分组合计quantity 并想生成不同国别分布的饼状图表,只列前10位,并且计算出每个国别占总数量的比例 10位以后的统称为其他,这个sql语句怎么写 有兴趣的朋友继续写写看楼上兄弟好意谢过select f1,f2,f3, cast(f2 as money) / cast(f3 as money) as 百分比 from (select country as f1, sum(quantity) as f2 from new group by country) A cross join (select sum(quantity) as f3 from new ) B 这个做出来是没问题的了,但是这个只是我自己练习写写的sql语句你看看你能否写出人家需要的真正要求吧
select f1,f2,f3,CDbl(f2)/CDbl(f3) as 总数 from ((select country as f1,sum(quantity) as f2 from new group by country)as A cross join (select sum(quantity) as f3 from new ) as B)
from ((select country as f1,sum(quantity) as f2 from new group by country) as A cross join (select sum(quantity) as f3 from new ) as B)
(
((select country as f1,sum(quantity) as f2 from new group by country)as A
cross join
(select sum(quantity) as f3 from new ) as B) )
WHERE F3<>0
5.4824561403508769E-3因为返回的值不可能大于1的 bugchen888(臭虫) 很可能正确我在qq群里看到网友发的问题非常有挑战性就自己写写
现在只是完成了其要求的一半功能他的要求是在这样的:
一个表中有三个字段为saler country quantity
我想按country分组合计quantity
并想生成不同国别分布的饼状图表,只列前10位,并且计算出每个国别占总数量的比例
10位以后的统称为其他,这个sql语句怎么写 有兴趣的朋友继续写写看
from (select country as f1, sum(quantity) as f2 from new group by country) A
cross join
(select sum(quantity) as f3 from new ) B
一个表中有三个字段为saler country quantity
我想按country分组合计quantity
并想生成不同国别分布的饼状图表,只列前10位,并且计算出每个国别占总数量的比例
10位以后的统称为其他,这个sql语句怎么写 有兴趣的朋友继续写写看楼上兄弟好意谢过select f1,f2,f3, cast(f2 as money) / cast(f3 as money) as 百分比
from (select country as f1, sum(quantity) as f2 from new group by country) A
cross join
(select sum(quantity) as f3 from new ) B
这个做出来是没问题的了,但是这个只是我自己练习写写的sql语句你看看你能否写出人家需要的真正要求吧