返回顶部

收藏

分享一个自己写的比较全的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 子句一起使用)

标签:sql

收藏

0人收藏

支持

0

反对

0

发表评论