Home > Database > Mysql Tutorial > 分享一个自己写的比较全的SQL语句

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

WBOY
Release: 2016-06-07 14:54:46
Original
1191 people have browsed it

最近要准备复习,考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 子句一起使用)
Copy after login
分享一个自己写的比较全的SQL语句
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template