最近要准备复习,考MSSERVER2005,就是相关的SQL语句总结了下,一般常用的就没写了,都是一些可能会用到,不经常用,但是也并不是不用的语法,希望对大家有用 SQL语句 SELECT DISINCT(学号),等级= CASEWHEN 总学分50 THEN '及格'WHEN 总学分80 THEN '很好'ELS
最近要准备复习,考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 子句一起使用)