首页 > 数据库 >sql语句

sql语句

时间:2023-06-13 09:34:56浏览次数:39  
标签:语句 CASE 00 15 07 30 2021 sql

SELECT
sum( CASE WHEN time BETWEEN '2021-07-15 00:00:00' AND '2021-07-15 00:30:00' THEN 1 ELSE 0 END ) AS '1',
sum( CASE WHEN time BETWEEN '2021-07-15 00:30:00' AND '2021-07-15 01:00:00' THEN 1 ELSE 0 END ) AS '2',
sum( CASE WHEN time BETWEEN '2021-07-15 01:00:00' AND '2021-07-15 01:30:00' THEN 1 ELSE 0 END ) AS '3',
sum( CASE WHEN time BETWEEN '2021-07-15 01:30:00' AND '2021-07-15 02:00:00' THEN 1 ELSE 0 END ) AS '4',
sum( CASE WHEN time BETWEEN '2021-07-15 02:00:00' AND '2021-07-15 02:30:00' THEN 1 ELSE 0 END ) AS '5',
sum( CASE WHEN time BETWEEN '2021-07-15 02:30:00' AND '2021-07-15 03:00:00' THEN 1 ELSE 0 END ) AS '6',
sum( CASE WHEN time BETWEEN '2021-07-15 03:00:00' AND '2021-07-15 03:30:00' THEN 1 ELSE 0 END ) AS '7',
sum( CASE WHEN time BETWEEN '2021-07-15 03:30:00' AND '2021-07-15 04:00:00' THEN 1 ELSE 0 END ) AS '8',
sum( CASE WHEN time BETWEEN '2021-07-15 04:00:00' AND '2021-07-15 04:30:00' THEN 1 ELSE 0 END ) AS '9',
sum( CASE WHEN time BETWEEN '2021-07-15 04:30:00' AND '2021-07-15 05:00:00' THEN 1 ELSE 0 END ) AS '10',
sum( CASE WHEN time BETWEEN '2021-07-15 05:00:00' AND '2021-07-15 05:30:00' THEN 1 ELSE 0 END ) AS '11',
sum( CASE WHEN time BETWEEN '2021-07-15 05:30:00' AND '2021-07-15 06:00:00' THEN 1 ELSE 0 END ) AS '12',
sum( CASE WHEN time BETWEEN '2021-07-15 06:00:00' AND '2021-07-15 06:30:00' THEN 1 ELSE 0 END ) AS '13',
sum( CASE WHEN time BETWEEN '2021-07-15 06:30:00' AND '2021-07-15 07:00:00' THEN 1 ELSE 0 END ) AS '14',
sum( CASE WHEN time BETWEEN '2021-07-15 07:00:00' AND '2021-07-15 07:30:00' THEN 1 ELSE 0 END ) AS '15',
sum( CASE WHEN time BETWEEN '2021-07-15 07:30:00' AND '2021-07-15 08:00:00' THEN 1 ELSE 0 END ) AS '16',
sum( CASE WHEN time BETWEEN '2021-07-15 08:00:00' AND '2021-07-15 08:30:00' THEN 1 ELSE 0 END ) AS '17',
sum( CASE WHEN time BETWEEN '2021-07-15 08:30:00' AND '2021-07-15 09:00:00' THEN 1 ELSE 0 END ) AS '18',
sum( CASE WHEN time BETWEEN '2021-07-15 09:00:00' AND '2021-07-15 09:30:00' THEN 1 ELSE 0 END ) AS '19',
sum( CASE WHEN time BETWEEN '2021-07-15 09:30:00' AND '2021-07-15 10:00:00' THEN 1 ELSE 0 END ) AS '20',
sum( CASE WHEN time BETWEEN '2021-07-15 10:00:00' AND '2021-07-15 10:30:00' THEN 1 ELSE 0 END ) AS '21',
sum( CASE WHEN time BETWEEN '2021-07-15 10:30:00' AND '2021-07-15 11:00:00' THEN 1 ELSE 0 END ) AS '22',
sum( CASE WHEN time BETWEEN '2021-07-15 11:00:00' AND '2021-07-15 11:30:00' THEN 1 ELSE 0 END ) AS '23',
sum( CASE WHEN time BETWEEN '2021-07-15 11:30:00' AND '2021-07-15 12:00:00' THEN 1 ELSE 0 END ) AS '24',
sum( CASE WHEN time BETWEEN '2021-07-15 12:00:00' AND '2021-07-15 12:30:00' THEN 1 ELSE 0 END ) AS '25',
sum( CASE WHEN time BETWEEN '2021-07-15 12:30:00' AND '2021-07-15 13:00:00' THEN 1 ELSE 0 END ) AS '26',
sum( CASE WHEN time BETWEEN '2021-07-15 13:00:00' AND '2021-07-15 13:30:00' THEN 1 ELSE 0 END ) AS '27',
sum( CASE WHEN time BETWEEN '2021-07-15 13:30:00' AND '2021-07-15 14:00:00' THEN 1 ELSE 0 END ) AS '28',
sum( CASE WHEN time BETWEEN '2021-07-15 14:00:00' AND '2021-07-15 14:30:00' THEN 1 ELSE 0 END ) AS '29',
sum( CASE WHEN time BETWEEN '2021-07-15 14:30:00' AND '2021-07-15 15:00:00' THEN 1 ELSE 0 END ) AS '30',
sum( CASE WHEN time BETWEEN '2021-07-15 15:00:00' AND '2021-07-15 15:30:00' THEN 1 ELSE 0 END ) AS '31',
sum( CASE WHEN time BETWEEN '2021-07-15 15:30:00' AND '2021-07-15 16:00:00' THEN 1 ELSE 0 END ) AS '32',
sum( CASE WHEN time BETWEEN '2021-07-15 16:00:00' AND '2021-07-15 16:30:00' THEN 1 ELSE 0 END ) AS '33',
sum( CASE WHEN time BETWEEN '2021-07-15 16:30:00' AND '2021-07-15 17:00:00' THEN 1 ELSE 0 END ) AS '34',
sum( CASE WHEN time BETWEEN '2021-07-15 17:00:00' AND '2021-07-15 17:30:00' THEN 1 ELSE 0 END ) AS '35',
sum( CASE WHEN time BETWEEN '2021-07-15 17:30:00' AND '2021-07-15 18:00:00' THEN 1 ELSE 0 END ) AS '36',
sum( CASE WHEN time BETWEEN '2021-07-15 18:00:00' AND '2021-07-15 18:30:00' THEN 1 ELSE 0 END ) AS '37',
sum( CASE WHEN time BETWEEN '2021-07-15 18:30:00' AND '2021-07-15 19:00:00' THEN 1 ELSE 0 END ) AS '38',
sum( CASE WHEN time BETWEEN '2021-07-15 19:00:00' AND '2021-07-15 19:30:00' THEN 1 ELSE 0 END ) AS '39',
sum( CASE WHEN time BETWEEN '2021-07-15 19:30:00' AND '2021-07-15 20:00:00' THEN 1 ELSE 0 END ) AS '40',
sum( CASE WHEN time BETWEEN '2021-07-15 20:00:00' AND '2021-07-15 20:30:00' THEN 1 ELSE 0 END ) AS '41',
sum( CASE WHEN time BETWEEN '2021-07-15 20:30:00' AND '2021-07-15 21:00:00' THEN 1 ELSE 0 END ) AS '42',
sum( CASE WHEN time BETWEEN '2021-07-15 21:00:00' AND '2021-07-15 21:30:00' THEN 1 ELSE 0 END ) AS '43',
sum( CASE WHEN time BETWEEN '2021-07-15 21:30:00' AND '2021-07-15 22:00:00' THEN 1 ELSE 0 END ) AS '44',
sum( CASE WHEN time BETWEEN '2021-07-15 22:00:00' AND '2021-07-15 22:30:00' THEN 1 ELSE 0 END ) AS '45',
sum( CASE WHEN time BETWEEN '2021-07-15 22:30:00' AND '2021-07-15 23:00:00' THEN 1 ELSE 0 END ) AS '46',
sum( CASE WHEN time BETWEEN '2021-07-15 23:00:00' AND '2021-07-15 23:30:00' THEN 1 ELSE 0 END ) AS '47',
sum( CASE WHEN time BETWEEN '2021-07-15 23:30:00' AND '2021-07-15 24:00:00' THEN 1 ELSE 0 END ) AS '48'

from potential_aaa111_60km_k11_11_21

标签:语句,CASE,00,15,07,30,2021,sql
From: https://www.cnblogs.com/watm/p/17476596.html

相关文章

  • 深入探究for...range语句
    1.引言在Go语言中,我们经常需要对数据集合进行遍历操作。对于数组来说,使用for语句可以很方便地完成遍历。然而,当我们面对其他数据类型,如map、string和channel时,使用普通的for循环无法直接完成遍历。为了更加便捷地遍历这些数据类型,Go语言引入了for...range语句。本文将以数组......
  • 压缩包版MySQL8安装
    1、下载解压链接:https://pan.baidu.com/s/11OxndQSx9GVP30chaGf7uA?pwd=1mfh提取码:1mfh2、新建ini文件在MySQL根目录新建(具有bin文件夹那一级)[mysqld]<!--设置3306端口-->port=3306<!--设置mysql的安装目录-->basedir=D:\File\Mysql\mysql-8.0.22-winx64<!--设置mysql......
  • 【MySQL的CheckPoint技术】
    MySQL的CheckPoint(CheckPoint)技术,又称"redolog"(Redolog),是MySQL数据库的核心技术之一,其目的是在发生故障或故障时,保证数据库中存储的数据可以得到有效的修复。对数据库进行的修改,包括写入,更新,删除等,都要进行相应的文档化,以确保数据在任何时候都是一致的。如何使用MySQL检查......
  • centos7 虚拟机安装 MySQL数据库
    检查是否安装过MySQL以及版本信息rpm-qa|grep-imysql卸载之前的版本,参数-e表示删除,-nodeps表示不校验依赖关系rpm-emysql-5.1.47-4.el6.x86_64–nodeps二进制包格式安装的mysql卸载如果我们的mysql是通过二级制包格式安装的,则rpm-qa|grep-imysql是......
  • NBU MSSQL SERVER
    #客户机中的操作   安装nbu客户端   hosts主、客户端修改   master端添加当前客户端   打开NetBackupMSSQLClientF7SetSQLServerconnectionpropertiesHost:主机名Instance:MSSQLSERVERUserid:administratorPassword:   生成脚本文件   BackupSQL......
  • Ubuntu-20.04.6-server安装MySQL实现远程连接
    Ubuntu-20.04.6-server安装MySQL,修改密码安装MySQL一、查看是否安装数据库mysql--version二、更新系统中的所有软件包和存储库sudoaptupdate三、安装Mysql最新版(我这里已经安装好了)sudoaptinstallmysql-server四、安装成功后,mysql--version查看版本五、查......
  • MySQL-MHA搭建
    1、测试环境目前MHA主要支持一主多从的架构,要搭建MHA,要求一个复制集群中必须最少有三台数据库服务器,一主二从,即一台充当master,一台充当备用master,另外一台充当从库.一主两从的环境,通过GTID方式配置主从复制同步环境用途IP地址安装软件MySQL版本主库db01192.168.3......
  • 熟悉常用的mysql增删改查命令
    增删改查,掌握基本的数据库基础操作命令1.创建数据库createdatabasepems2;这个是连接数据库的工具查询已有的数据库,也可以在服务器进入数据库命令行查询mysql>showdatabases;+--------------------+|Database|+--------------------+|information_schema||mysql......
  • Docker 安装 MySQL8 数据库
    创建数据卷mkdir-p/usr/mysql/conf/usr/mysql/datachmod-R755/usr/mysql/创建配置文件vim/usr/mysql/conf/my.cnf:[client]#socket=/usr/mysql/mysqld.sockdefault-character-set=utf8mb4[mysqld]#pid-file=/var/run/mysqld/mysqld.pid#sock......
  • Qt打包程序移动到新环境时提示 QMYSQL driver not loaded
    Qt版本是:Qt6.3.2MySQL版本是:mysql8.0.33运行时日志提示如下:Warning:File:()Line:(0)QSqlDatabase:QMYSQLdrivernotloaded(2023-06-1217:16:56)Warning:File:()Line:(0)QSqlDatabase:availabledrivers:QSQLITEQMARIADBQMYSQLQODBCQPSQL(2023-06-1217:16:56)......