Sql小练习

请按照要求写出sql语句
表内容:
datetime    result
2005-05-09 胜
2005-05-09 胜
2005-05-09 负
2005-05-09 负
2005-05-10 胜
2005-05-10 负
2005-05-10 负

生成下列结果,怎样写sql

          胜  负
2005-05-09  2   2
2005-05-10  1   2



select [datetime],SUM(case when  result='胜' then 1 else 0 end) ,
SUM(case when   result='负' then 1 else 0 end) from [表名]   group by [datetime]


用一SQL语句   查询出每门课都大于80分的学生姓名,表(MarkList)如下:
                             
Name   Course    Mark
张三   语文       81
张三   数学       75
 
王五    英语      100
王五    语文      81

正确:
select name from MarkList where  Name not in ( select Name From MarkList where  (mark < 80) ) group by name

Sql 中取小数点后面两位小数.
select convert(numeric(8,2),round(UnTaxAmount,2))as UnTaxAmount from View_SaleVoice

select   cast(UnTaxAmount as decimal(20,2)) as UnTaxAmount   from View_SaleVoice

 


                                                                                              

posted @ 2012-10-22 16:03  瓦罐  阅读(133)  评论(0)    收藏  举报