两张表,table1,score
table1的ID对应accountScore的ID,accountScore的score的值是decm/(decm的和)
若accountScore的表,ID为1的score的值就为20/(20+30+40+50)
这个存储过程怎么写?table1
id decm
1 20
2 30
3 40
4 50
... ...accountScore
id score
table1的ID对应accountScore的ID,accountScore的score的值是decm/(decm的和)
若accountScore的表,ID为1的score的值就为20/(20+30+40+50)
这个存储过程怎么写?table1
id decm
1 20
2 30
3 40
4 50
... ...accountScore
id score
我之前也是像你这么写的,可是score总是为0,是不是字段的类型不对?我用的是double,float都试过,都为0.
select b.decm from accountScore a,table1 b, where a.id=b.id
select sum(decm) from table1
FLOAT[(M,D)] [UNSIGNED] [ZEROFILL] A small (single-precision) floating-point number. Allowable values are -3.402823466E+38 to -1.175494351E-38, 0, and 1.175494351E-38 to 3.402823466E+38. These are the theoretical limits, based on the IEEE standard. The actual range might be slightly smaller depending on your hardware or operating system.
DOUBLE[(M,D)] [UNSIGNED] [ZEROFILL] A normal-size (double-precision) floating-point number. Allowable values are -1.7976931348623157E+308 to -2.2250738585072014E-308, 0, and 2.2250738585072014E-308 to 1.7976931348623157E+308. These are the theoretical limits, based on the IEEE standard. The actual range might be slightly smaller depending on your hardware or operating system.