sql-select

SELECT

 

1. SELECT SNO,NAME,SHU+YU+YIN AS SUM, (SHU+YU+YIN)/3 AS AVG FROM TAB_STU;

  2  SELECT DISTINCT DEPT FROM TAB_STU;

                 SELECT DISTINCT LER FRON TAB_STU

3. 使用top n:返回前n条记录

使用 top n percent :返回前n%条记录

使用set rowcount n:返回前n条记录

SELECT TOP 5 FROM TAB_STU;

SELECT TOP 20 PERCENT * FROM TAB_STU;

SET ROWCOUNT 5 ;SELECT * FROM TAB_STU

4. 条件子句的使用

SELECT * FROM TAB_STU WHERE SEX=’MAN’;

SELECT DEPT ,COUNT(*) FROM TAB_STU WHERE SEX=’MAN’ GROUP BY DEPT HAVING COUNT(*)>10


        5. SELECT * FROM TAB_STU ORDER BY NAME;

     SELECT TOP 5 * FROM STU ORDER BY MATH DESC ;

    还得补充


你可能感兴趣的:(sql-select)