|
if object_id('H_COUNT') is not null drop table H_COUNT go create table H_COUNT(H_DAY varchar(10),H_CON int,H_NAME varchar(10)) insert H_COUNT select '2007-1-10',10,'收入' union all select '2007-1-11',20,'收入' union all select '2007-1-10',5,'支出' union all select '2007-1-11',3,'支出' select H_DAY as 日期,max(case when H_NAME='收入' then H_CON end) as 收入, max(case when H_NAME='支出' then H_CON end) as 支出 from H_COUNT group by H_DAY 正确 接分
|