开发者社区> 问答> 正文

used with SELECT query in SQL?

已解决

What are some common clauses used with SELECT query in SQL?

展开
收起
1780169608831412 2021-10-16 15:01:17 643 0
2 条回答
写回答
取消 提交回答
  • 网络规划设计师、敏捷专家、CISP、ITSS服务经理、ACA全科目、ACP4项、ACE、CBP、CDSP、CZTP等。拥有 PRINCE2 Foundation/Practitioner、CCSK、ITIL、ISO27001、PMP等多项国际认证。 专利5+、期刊10+、知识产权师。核心期刊审稿人。
    采纳回答

    Some common SQL clauses used in conjuction with a SELECT query are as follows:

    WHERE clause in SQL is used to filter records that are necessary, based on specific conditions.

    ORDER BY clause in SQL is used to sort the records based on some field(s) in ascending (ASC) or descending order (DESC).

    SELECT *
    FROM myDB.students
    WHERE graduation_year = 2019
    ORDER BY studentID DESC;
    
    

    GROUP BY clause in SQL is used to group records with identical data and can be used in conjunction with some aggregation functions to produce summarized results from the database.

    HAVING clause in SQL is used to filter records in combination with the GROUP BY clause. It is different from WHERE, since the WHERE clause cannot filter aggregated records.

    SELECT COUNT(studentId), country
    FROM myDB.students
    WHERE country != "INDIA"
    GROUP BY country
    HAVING COUNT(studentID) > 5;
    
    2021-10-16 16:19:07
    赞同 1 展开评论 打赏
  • mysql> select * from books;
    +------+--------+------+
    | name | author | jb   |
    +------+--------+------+
    | lkj  | NULL   | NULL |
    | lkj  | NULL   | NULL |
    | lkj  | NULL   | NULL |
    +------+--------+------+
    3 rows in set (0.00 sec)
    
    mysql> select name ,author from books;
    +------+--------+
    | name | author |
    +------+--------+
    | lkj  | NULL   |
    | lkj  | NULL   |
    | lkj  | NULL   |
    +------+--------+
    3 rows in set (0.00 sec)
    
    2021-10-16 17:37:12
    赞同 展开评论 打赏
问答分类:
SQL
问答地址:
问答排行榜
最热
最新

相关电子书

更多
SQL Server 2017 立即下载
GeoMesa on Spark SQL 立即下载
原生SQL on Hadoop引擎- Apache HAWQ 2.x最新技术解密malili 立即下载