最近要准备复习,考msserver2005,就是相关的sql语句总结了下,一般常用的就没写了,都是一些可能会用到,不经常用,但是也并不是不用的语法,希望对大家有用 sql语句 select disinct(学号),等级= case when 总学分>50 then '及格' when 总学分>80 then '很好' else '优秀' end, top(5) [percent] into tb_name_other from tb_name cross join tb_second_name where th_colnum = 'xxxx' and name like '%王#_%' escape '#' and major in ('计算机','软件','通信') and birthday not between 'a' and 'b' and contains(*,'工程') and freetext(*,'作业') group by expression with cube /with rollup having expression order by expression compute count(学号) by 专业 union all select * from tb_third_name where 学号='xxxx' except/intersect select * from tb_forth_name where 性别='1'(不能与compute 子句一起使用)
