分享一个自己写的比较全的SQL语句

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

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 子句一起使用)