zoukankan      html  css  js  c++  java
  • group by,case then

    在带有group by 子句的查询语句中,在select 列表中指定的列要么是group by 子句中指定的列,要么包含聚组函数
    select ClientMediaTypeID,count(ID) from Table group by Table.ClientMediaTypeID having ClientMediaTypeID>30 

      当在gropu by 子句中使用having 子句时,查询结果中只返回满足having条件的组。在一个sql语句中可以有where子句和having子句。having 与where 子句类似,均用于设置限定条件


    select table.字段,(case when table.CityID<=50 then '不行'
    when table.CityID>=50 then '行' else '不清楚' end) 'case列名' from HJ_AllNews

    select table.字段,(case table.userName when '张山' then '不行' 
    when ‘李四’ then '行' else '不清楚' end) 'case列名' from HJ_AllNews

    使用case then时,如果case后面是表里的字段 when后就是字段具体的值,不能有算术表达式。唉,浪费这么大会。。小白啊啊


     

  • 相关阅读:
    4. Dictionary HashTable
    5.1. ISet HashSet
    5.2.ISet SortedSet
    6.1. String
    6.2. Encoding
    2.1. List
    1. 基础类型
    0.源代码代码分布情况
    0.2.比较接口Default
    Android获取应用启动时间
  • 原文地址:https://www.cnblogs.com/smailxiaobai/p/2252854.html
Copyright © 2011-2022 走看看