select i.id as id,i.game as gm, i.name as name, sp.LV as lv, sp.A as A,sp.B as B from T_item as i left join T_itemSp as sp on i.id = sp.ItemID where sp.ItemID = 15 A~B 是根据lv的值来决定 比如说lv有5 那么 就是sp.A~sp.E 最多到Z如何求的 A~B 的百分比id gm name lv A B
15 1 test 2 100 100我要求A 和 B的 百分比 比如 A 50% B 50%不知道SQL语句能不能实现?
或者VB.NET代码如何实现?
15 1 test 2 100 100我要求A 和 B的 百分比 比如 A 50% B 50%不知道SQL语句能不能实现?
或者VB.NET代码如何实现?
15 1 test 2 100 100 是按A,B对分?
如果 lv是5 那么查询的字段就有 a b c d e我是要 比如a~z 这些字段中 ,每个字段占到了100%中的 %多少
from ta
id gm name lv A B
15 1 test 2 100 100
-----------------------------------------
直接把这个结果按百分比输出:
create table yu(id int,gm int,name varchar(10),lv int,A int,B int)
insert into yu select 15, 1 , 'test' , 2 , 100 , 100
select a=ltrim(cast(a*100.0/(a+b) as numeric(5,2)))+'%',
b=ltrim(cast(b*100.0/(a+b) as numeric(5,2)))+'%'
from yu
lvs += "sp." & cs(x) & " as " & cs(x) & ","
tb(x) = cs(x)
Nextdb.SQL = "select i.id as id,i.game as gm, i.name as name, sp.LV as lv, " & lvs & " " _
& "from T_item as i left join T_itemSp as sp on i.id = sp.ItemID where sp.ItemID = " & id & ""lvs 是我根据 lv长度拼接起来的