日期:2014-05-17  浏览次数:20640 次

sql 语句 查询


                      表 A
                      
        时间              人       手机      电脑      笔
     
2012-06-25 11:06:11      张三       1         0         1

2012-06-25 14:06:11      张三       0         0         1

2012-06-26 12:06:11      张三       1         0         1

2012-06-26 12:06:11      李四       1         0         1

2012-06-26 12:06:11      李四       1         0         1



结果是:
             表 A
                      
       时间         人       手机      电脑      笔
     
    2012-06-25     张三       1         0         2

    2012-06-26     张三       1         0         1

    2012-06-26     李四       2         0         2

求SQL 语句

------解决方案--------------------

select convert(varchar(10),时间,120) 时间,人,sum(手机) 手机,sum(电脑) 电脑,sum(笔) 笔
from A
group by convert(varchar(10),时间,120),人