不用存储过程写行不行?不行的话你自己改了select f_Year,f_Month,
case(f_Quantity as numeric(10,2))*f_Price/(select sum(f_Quantity*f_Price) from t1 where f_Year=a.f_Year) as f_Pro, f_Price
from t1 a
where f_Month =1还是:
select f_Year,f_Month,
case(f_Quantity as numeric(10,2))/(select sum(f_Quantity ) from t1 where f_Year=a.f_Year) as f_Pro, f_Price
from t1 a
where f_Month =1
没细算,哪个对不知道,全错了就不管了哈,哈哈,哈哈哈......
case(f_Quantity as numeric(10,2))*f_Price/(select sum(f_Quantity*f_Price) from t1 where f_Year=a.f_Year) as f_Pro, f_Price
from t1 a
where f_Month =1还是:
select f_Year,f_Month,
case(f_Quantity as numeric(10,2))/(select sum(f_Quantity ) from t1 where f_Year=a.f_Year) as f_Pro, f_Price
from t1 a
where f_Month =1
没细算,哪个对不知道,全错了就不管了哈,哈哈,哈哈哈......
解决方案 »
- C#的winfrom程序怎么打包后把sqllite保存在客户端
- 关于字母匹配汉字
- 本人刚学数据库,恳请各位帮忙。
- SQL Server 2000截断日志需要断开客户端连接么?
- sql 让字段竖着显示
- 求助:SQL Server查询
- 十万火急,在线等待!
- 如何在sql server中把查询结果集导出到一个excel文件中?注意:这个excel文件是自动生成的,而不是一个已经存在的excel文件!
- 有人知道在ASP中如何实现对多个SQL SERVER数据表的查询,之后把查询结果存放到一个recordset对象中吗?高分!
- Oracle转sqlserver问题
- 简单可我就是不会SQL语句请教!!!!关于分组的
- 请问:在SQLserver中,日期型数据如何表示?
select a.f_year,
b.f_month,
[f_pro]=(select sum(f_quantity*f_price) from ttt c where c.f_year=a.f_year)/
(select f_quantity*f_price from ttt d where d.f_year=a.f_year and d.f_month=1),
b.f_price
from
(select f_year from ttt group by f_year) a
join
ttt b
on a.f_year=b.f_year
where b.f_month=1
刚才搞错啦
select a.f_year,
b.f_month,
[f_pro]=(select f_quantity*f_price from ttt d where d.f_year=a.f_year and d.f_month=1)/
(select sum(f_quantity*f_price) from ttt c where c.f_year=a.f_year),
b.f_price
from
(select f_year from ttt group by f_year) a
join
ttt b
on a.f_year=b.f_year
where b.f_month=1
f_year f_month f_pro f_price
----------- ----------- ---------------------------------------- ------------
2000 1 .05555555555555555 .30
2001 1 .07272727272727272 .40(所影响的行数为 2 行)
@month varchar(10)
as
select distinct (b.s_year),b.s_month,cast(s_qty as decimal(10,4))/(select sum(s_qty ) from shouru as c where c.s_year=a.s_year )as f_pro,b.s_price from shouru as b
join (select s_year from shouru group by s_year) as a
on a.s_year=b.s_year
where b. s_month=@month
GO