首页 > 数据库 >SQL26_ 计算25岁以上和以下的用户数量

SQL26_ 计算25岁以上和以下的用户数量

时间:2022-10-26 20:58:52浏览次数:65  
标签:count 25 age 计算 24 SQL26 null 用户数量

通过代码

1 2 3 4 5 6 7 select '25岁以下', count(ifnull(age, 24)) as number from user_profile  where age < 25&nbs***bsp;age is null union  select '25岁及以上', count(age) as number from user_profile  where age >= 25

总结

0.count计算查询结果有多少条记录,不算null。

1.判断是不是空举例:age is null, age is not null。 2.count和空:查询结果只有age一列,null的记录不算,查询结果有多列,一条记录全是null不被count计算。 3.count(ifnull(age, 24)),一条记录的age若为空,改成24,再参加计算。
4.直接加字符串 25岁以下 和 25岁及以上 就行。那这一列叫啥名呢?

标签:count,25,age,计算,24,SQL26,null,用户数量
From: https://www.cnblogs.com/JuniorProgramer/p/16829964.html

相关文章

  • 单调栈--HDOJ4252A Famous City
    ProblemDescriptionAfterMr.BarrivedinWarsaw,hewasshockedbytheskyscrapersandtookseveralphotos.Butnowwhenhelooksatthesephotos,hefindsin......
  • SQL25_查找山东大学或者性别为男生的信息
    通过的代码  1234567select device_id, gender, age, gpafrom user_profilewhere university = '山东大学' union allselect dev......
  • 洛谷P2512 [HAOI2008]糖果传递
    SLOJP1117.糖果传递题目描述有n个小朋友坐成一圈,每人有ai个糖果。每人只能给左右两人传递糖果。每人每次传递一个糖果代价为11。输入格式小朋友个数n,下面n行ai​......
  • 图像处理:ColorMap将灰度图像[0,1]区间上的像素值映射到RGB的[0,255]
    1.起因在做人群计数时,常常使用密度图来估计人数。密度图中每个像素的值都是介于0和1之间的浮点数,原本是灰度图。但是使用python的matplotlib.pyplot并指定cmap参数可以画......
  • 10.25 解题报告
    T1用时:1.5h赛时\(30\)min切了,对着错大样例调了\(1\)h。#include<bits/stdc++.h>#definelllonglong#defineintlonglong//#defineullunsignedlonglong#......
  • .NET周报【10月第3期 2022-10-25】
    国内文章聊一聊被.NET程序员遗忘的COM组件https://www.cnblogs.com/huangxincheng/p/16799234.html将Windows编程中经典的COM组件拿出来再复习一下,解释了COM组件互......
  • 2022.10.25 总结
    B有一个长度为\(n\)的排列,你可以进行若干操作,每次操作选择相邻的两个数并删去较大的数。问最后可以生成多少不同的序列。设\(f_i\)为以\(i\)为结尾的序列数。\(f......
  • 【2022.10.25】尝试自写一个Dockerfile
    前言用了别人这么多的docker,因为mirai的旧版本登不上了这次要自写一个docker了因为mirai运行在openjdk环境下运行,所以首先最开始的内容便是FROMopenjdk:17-slim-buster......
  • 10.25.2
    #include<stdio.h>#include<math.h> intmain(){/* inta,b; scanf("%*6d%4d%*8d%d",&a,&b); printf("%d",b-a);*/ doublea; scanf("%lf",&a); printf("%d,%.10g......
  • 2022-10-25学习内容_step01
    1.案例-找回密码-登录界面1.1activity_login_main.xml<?xmlversion="1.0"encoding="utf-8"?><LinearLayoutxmlns:android="http://schemas.android.com/apk/res/and......