欢迎投稿

今日深度:

sql纵表转换成横表,sql纵表

sql纵表转换成横表,sql纵表


数据库中 将一张纵表转换为一张横表

数据库纵表数据


sql语句如下

select cardid,
max(case t.projectcode when 'IA-002' then t.result  end) as ht,
max(case t.projectcode when 'IA-003' then t.result end) as wt,
max(case t.projectcode when 'IA-005' then t.result  end) as bmi,
max(case t.projectcode when 'IA-000' then t.result  end) as xl,
max(case t.projectcode when 'CG-005' then t.result end) as xybhd,
max(case t.projectcode when 'CD-002' then t.result  end) as kfxt,
max(case t.projectcode when 'CD-003' then t.result  end) as chxt,
max(case t.projectcode when 'IA-014' then t.result end) as xy,
max(case t.projectcode when 'JA-001' then t.result  end) as xd,datetime 
from projectresultinfo t group by t.cardid  order by datetime desc 


www.htsjk.Com true http://www.htsjk.com/shujukunews/5377.html NewsArticle sql纵表转换成横表,sql纵表 数据库中 将一张纵表转换为一张横表 数据库纵表数据 sql语句如下 select cardid,max(case t.projectcode when IA-002 then t.result end) as ht,max(case t.projectcode when IA-003 then t...
评论暂时关闭