zoukankan      html  css  js  c++  java
  • sql (9) COUNT

    COUNT() 函数返回匹配指定条件的行数。
    语法
    SQL COUNT(column_name) 语法
    COUNT(column_name) 函数返回指定列的值的数目(NULL 不计入):
    新建表
    StudentS
    S_id Grade Name phone
    1 98 小明 123456
    2 97 小黄 232456
    3 95 小哩 987654
    4 93 小小 654321
    5 90 微微 321065
    6 93 小小 654321
    7 95 微微 321065
    查询:
    select count(Grade) as Gradecount from StudentS
    where Grade=93
    效果:
    Gradecount
    2
    在表中有两行是分数为93的:
    4 93 小小 654321
    6 93 小小 654321


    select count(Grade) as Gradecount from StudentS
    where Grade=95
    效果:
    Gradecount
    2
    在表中有两行是分数为95的:
    3 95 小哩 987654
    7 95 微微 321065


    select count(Name) as Namecount from StudentS
    where Name=小明'
    效果:
    Namecount
    1
    在SturdentS表中名字为小明的行数为1:
    S_id Grade Name phone
    1 98 小明 123456


    select count(Name) as Namecount from StudentS
    where Name='小小'

    效果:
    Namecount
    2
    在SturdentS表中名字为小明的行数为1:
    S_id Grade Name phone

    4 93 小小 654321

    6 93 小小 654321

    2018-04-27    15:00:15

  • 相关阅读:
    自考新教材-p209
    自考新教材-p205
    自考新教材-p200
    自考新教材-p197
    Java IO (5)
    Java IO (1)
    Java IO (2)
    Java IO (3)
    通过源码学Java基础:InputStream、OutputStream、FileInputStream和FileOutputStream
    Spring入门(1)-第一个Spring项目
  • 原文地址:https://www.cnblogs.com/guangzhou11/p/8962475.html
Copyright © 2011-2022 走看看