zoukankan      html  css  js  c++  java
  • sql第三天

    -》完整的select语句及执行顺序(必须记住)

    5...select 5.2->distinct 7...top n [percent] 5.1->列名 聚合函数(1.2->列名或表达式)

    1...1.1->from 表名

    2...where 条件

    3...group by ... 4...having ...

    6...order by ...

    -》实际练习

    select distinct top 1 tsclassid,COUNT(*) AS 人数,avg(tsage) as 平均年龄

    from tblstudent

    where tsGender='男'

    group by tsclassid having tsclassid>3

    order by 平均年龄 desc

    -》问执行顺序是如何?

    1、from tblstudent

    2、where tsGender='男'

    3、group by tsclassid

    4、having tsclassid>3

    5、select

    5.1 tsclassid,COUNT(*) AS 人数,avg(tsage) as 平均年龄

    5.2 distinct

    6、order by 平均年龄 desc

    7、top 1

    inner join(等值连接) 只返回两个表中联结字段相等的行

    left join(左联接) 返回包括左表中的所有记录和右表中联结字段相等的记录

    right join(右联接) 返回包括右表中的所有记录和左表中联结字段相等的记录

  • 相关阅读:
    Python2 cmp() 函数
    Python round() 函数
    Python floor() 函数
    Python ceil() 函数
    Python abs() 函数
    Python oct() 函数
    Python ord() 函数
    Python hex() 函数
    Python2 unichr() 函数
    Android--------工具类StatusBarUtil实现完美状态栏
  • 原文地址:https://www.cnblogs.com/ggsdduzbl/p/5280271.html
Copyright © 2011-2022 走看看