• 主页
• 基础类
• 应用实例
• 新技术前沿

# 请教 求百分比

dsqempress 2008-01-24 12:16:41
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

id gm name lv A B
15 1 test 2 100 100

...全文
63 点赞 收藏 9

9 条回复

liangCK 2008-01-24

dsqempress 2008-01-24
For x As Integer = 0 To lv - 1
lvs += "sp." & cs(x) & " as " & cs(x) & ","
tb(x) = cs(x)
Next

db.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长度拼接起来的

pt1314917 2008-01-24
``````
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
``````

dawugui 2008-01-24

-狙击手- 2008-01-24
select a,b,a*1.0/(a+b) as A百分比,b*1.0/(a+b) as B百分比
from ta

liangCK 2008-01-24

dsqempress 2008-01-24
A B并不固定 根据 lv增长

dawugui 2008-01-24

dawugui 2008-01-24
id gm name lv A B
15 1 test 2 100 100

MS-SQL Server

3.2w+

MS-SQL Server相关内容讨论专区