SQL vertical table to horizontal table, SQL vertical table
Converts a vertical table to a horizontal table in the database.
Database vertical table data
The SQL statement is as follows:
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