Mysql sql语句积累

分组排序

#alter table zxfw_offline_qa add zx_number varchar(50) COMMENT '咨询编号,提问日期+提问顺序' AFTER id;/*
select (@i := case  when  @pre_consult_time=consult_time then @i + 1 else 1 end )  rownum,  qa.*,(@pre_consult_time:=consult_time)  from  zxfw_offline_qa qa, (SELECT  @i := 0, @pre_consult_time:='') AS a  group  by consult_time,id order by consult_time*/# 表增加字段
alter table zxfw_offline_qa add zx_number varchar(50) COMMENT '咨询编号,提问日期+提问顺序' AFTER id;# 创建临时表DROP TABLE IF EXISTS `offline_temp`;
CREATE TABLE `offline_temp`  (`id` int(11),`zx_number` varchar(50)
);# 把分组排序的值插入临时表
insert into offline_temp
select b.id,CONCAT(b.consult_time,'-',b.rownum) zx_number
from
(
select (@i := case  when  @pre_consult_time=consult_time then @i + 1 else 1 end )  rownum,  qa.id,qa.consult_time,(@pre_consult_time:=consult_time)  from  zxfw_offline_qa qa, (SELECT  @i := 0, @pre_consult_time:='') AS a  group by consult_time,id) b;# 更新线下咨询表 update zxfw_offline_qa set zx_number='';update zxfw_offline_qa a inner join offline_temp bon a.id=b.idset a.zx_number=b.zx_number;#查询结果select * from zxfw_offline_qa ORDER BY consult_time;

 

 

禅道统计工时

select u.realname as '姓名',t.worktimes as '工时' from (
select finishedBy,round(SUM(consumed),2) as worktimes from zt_task where LENGTH(finishedBy)>0 and project=18 GROUP BY finishedBy
) t,zt_user u where t.finishedBy=u.account order by worktimes;

 

随机100条

select * from tdw  ORDER BY RAND() LIMIT 100;

 

/*
UPDATE dati0917 dtINNER JOINygh_user u ON dt.idcards=u.ID_CARD_NUM
SET dt.app_phone = u.LOGIN_NAME;*/

#select length(csfz) from hzbz;#select LENGTH(cert_no) from weixin;#select cert_no from weixin where LENGTH(cert_no)>18;#SELECT count(0) as hznum from hzbz;
#SELECT count(0) as wxnum from weixin;
#SELECT count(0) as 51num from wuyi_card;
#SELECT count(0) as appnum from ygh;#数据清理#delete from wuyi_card where length(wuyi_card_no)=0;#update weixin set cert_no=trim(cert_no);#update hzbz set csfz=trim(csfz);#update wuyi_card set cert_no=trim(cert_no);#update ygh set ID_CARD_NUM=trim(ID_CARD_NUM);#查询不正常身份证
#select cert_no as wx_sfz from weixin where LENGTH(cert_no)<>18 and LENGTH(cert_no)<>15;
#select csfz as hzbz_sfz from hzbz where LENGTH(csfz)<>18 and LENGTH(csfz)<>15;
#select cert_no as 51_sfz from wuyi_card where LENGTH(cert_no)<>18 and LENGTH(cert_no)<>15 and wuyi_card_no is not null;
#select ID_CARD_NUM as app_sfz from ygh where LENGTH(ID_CARD_NUM)<>18 and LENGTH(ID_CARD_NUM)<>15;#查出重复数据#select cert_no as wx_sfz from weixin where cert_no in (select cert_no from weixin group by cert_no having count(cert_no)>1);#select csfz as hzbz_sfz from hzbz where csfz in (select csfz from hzbz group by csfz having count(csfz)>1);#select cert_no as 51_sfz from wuyi_card where cert_no in (select cert_no from wuyi_card group by cert_no having count(cert_no)>1);#select ID_CARD_NUM as app_sfz from ygh where ID_CARD_NUM in (select ID_CARD_NUM from ygh group by ID_CARD_NUM having count(ID_CARD_NUM)>1);#删除不正常身份证#delete from weixin where LENGTH(cert_no)<>18 and LENGTH(cert_no)<>15;
#delete from hzbz where LENGTH(csfz)<>18 and LENGTH(csfz)<>15;
#delete from wuyi_card where LENGTH(cert_no)<>18 and LENGTH(cert_no)<>15;
#delete from ygh where LENGTH(ID_CARD_NUM)<>18 and LENGTH(ID_CARD_NUM)<>15;#删除重复数据,多执行几次/*
DELETE FROM ygh 
WHERE id IN 
(SELECT id FROM (SELECT id FROM ygh GROUP BY ID_CARD_NUM HAVING count(*) > 1)e);
*/#进行标识
#51工会卡认证#update hzbz set wuyika='YES' WHERE csfz IN (select csfz from (select hzbz.csfz FROM hzbz,wuyi_card where hzbz.csfz=wuyi_card.cert_no) a);#update hzbz set weixin='YES' WHERE csfz IN (select csfz from (select hzbz.csfz FROM hzbz,weixin where hzbz.csfz=weixin.cert_no) a);#update hzbz set app='YES' WHERE csfz IN (select csfz from (select hzbz.csfz FROM hzbz,ygh where hzbz.csfz=ygh.ID_CARD_NUM) a);#SELECT count(0) as 51RZ from hzbz where wuyika='YES';
#SELECT count(0) as WXRZ from hzbz where weixin='YES';
#SELECT count(0) as APPRZ from hzbz where app='YES';
#SELECT count(0) as ALLRZ from hzbz where app='YES' AND wuyika='YES' AND weixin='YES';#按产业和区导出/*
select DISTINCT(cxtbh) from hzbz;select * from hzbz where cxtbh='海曙区';
select * from hzbz where cxtbh='财贸';
select * from hzbz where cxtbh='文卫';
select * from hzbz where cxtbh='海曙区';
select * from hzbz where cxtbh='海曙区';
select * from hzbz where cxtbh='海曙区';
select * from hzbz where cxtbh='海曙区';
select * from hzbz where cxtbh='海曙区';
select * from hzbz where cxtbh='海曙区';
select * from hzbz where cxtbh='海曙区';
select * from hzbz where cxtbh='海曙区';
select * from hzbz where cxtbh='海曙区';select * from hzbz where cdwm='宁波市海曙区段塘街道洞桥社区';*/#update hzbz0527 set wuyika='YES' WHERE csfz IN (select csfz from (select hzbz0527.csfz FROM hzbz0527,wuyi_card where hzbz0527.csfz=wuyi_card.cert_no) a);#update hzbz0527 set weixin='YES' WHERE csfz IN (select csfz from (select hzbz0527.csfz FROM hzbz0527,weixin0527 where hzbz0527.csfz=weixin0527.cert_no) a);#update hzbz0527 set app='YES' WHERE csfz IN (select csfz from (select hzbz0527.csfz FROM hzbz0527,ygh where hzbz0527.csfz=ygh.ID_CARD_NUM) a);#去除奇怪的空格
#update hzbz0527 set csfz=replace(csfz,' ','');#update hzbz0527 set remark=null;#标识错误身份证号#update hzbz0527 set remark='身份证格式错误' where LENGTH(csfz)<>18 and LENGTH(csfz)<>15;#标识重复身份证号/*
update hzbz0527 set remark='身份证重复' where csfz in (
select a.hzbz_sfz from
(select csfz as hzbz_sfz from hzbz0527 where csfz in (select csfz from hzbz0527 group by csfz having count(csfz)>1)
) a);
*/

 

SELECT
count(status = 0 OR NULL) AS a,
count(status = 1 OR NULL) AS b,
count(status = 2 OR NULL) AS c,
count(status = 3 OR NULL) AS d,
count(status = 4 OR NULL) AS e
FROM table;OR NULL必须要有

 

 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/537762.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

中缀表达式转换成后缀表达式(只适用于加减乘除运算)

1 #include <iostream>2 #include <stack>3 #include <cctype>4 5 using namespace std;6 7 //获取符号的优先级8 int getPriority(char c)9 { 10 int priority -1; 11 switch (c) { 12 case : 13 priority 1; 14 break; 15 …

android多接口请求参数,okhttp3 使用json参数post方式请求接口数据(android)

1. 谷歌自带的json不支持像map一样直接put字符串进去&#xff0c;所以先导入阿里的json包2. 创建json对象&#xff0c;并且放入所要请求的参数 //登录 private void loginRequest() { String url Contents.url"login"; JSONObject json new JSONObject(); json.put…

由浅入深,一文掌握NGINX知识文集

&#x1f3c6;作者简介&#xff0c;普修罗双战士&#xff0c;一直追求不断学习和成长&#xff0c;在技术的道路上持续探索和实践。 &#x1f3c6;多年互联网行业从业经验&#xff0c;历任核心研发工程师&#xff0c;项目技术负责人。 &#x1f389;欢迎 &#x1f44d;点赞✍评论…

MySQL not in查询不出数据(MySQL not in 无效)

今天使用 MySQL 的 not in 进行查询的时候&#xff0c;发现结果里面并没有返回任何数据。SQL 语句没有任何问题&#xff0c;但是结果集却是空&#xff0c;实在无法理解。纠结了半天&#xff0c;最后使用 left join&#xff0c;两表关联&#xff0c;找到了目标数据。但是这样的话…

Python语法特点如注释规则、代码缩进、编码规范等

在Python中&#xff0c;通常包括3种类型的注释&#xff0c;分别是单行注释、多行注释和中文编码声明注释。单行注释在Python中&#xff0c;使用“#”作为单行注释的符号。从符号“#”开始直到换行为止&#xff0c;“#”后面所有的内容都作为注释的内容&#xff0c;并被Python编…

修改android.jar教程,Android修改jar包文件

1、Android studio中新建java文件&#xff0c;取和将要修改的文件相同的文件名&#xff0c;把class文件中代码复制过去&#xff0c;修改需要改动的代码2、新建txt文件&#xff0c;将新建的Java文件按照依赖关系将路经添加到新建的txt文件中&#xff0c;被依赖的放在最前面(ps:此…

安卓市场上架总结

安卓上架截图&#xff08;不要带手机外观&#xff09; 注意&#xff1a;截图不能有二维码小米 至少3张&#xff0c;480*854像素&#xff0c;JPG、PNG格式。腾讯应用宝 请上传2-5张截图&#xff08;尺寸保持一致&#xff09;&#xff0c;单张图片不超过1M。截图不能小于320*480像…

android 左右分栏联动布局,Layout 布局(24 分栏)

基础布局使用单一分栏创建基础的栅格布局(:span“0~24”).el-row {margin-bottom: 20px;&:last-child {margin-bottom: 0;}}.el-col {border-radius: 4px;}.bg-purple-dark {background: #99a9bf;}.bg-purple {background: #d3dce6;}.bg-purple-light {background: #e5e9f2…

洛谷P4238 【模板】多项式求逆(NTT)

传送门 学习了一下大佬的->这里 已知多项式$A(x)$&#xff0c;若存在$A(x)B(x)\equiv 1\pmod{x^n}$ 则称$B(x)$为$A(x)$在模$x^n$下的逆元&#xff0c;记做$A^{-1}(x)$ 具体的来说的话&#xff0c;就是两个多项式$A,B$相乘模$x^n$之后&#xff0c;所有次数大于等于$n$的项都…

win10安装TortoiseGit

TortoiseGit 是Git的可视化工具。所以前提是已经安装了Git&#xff0c;安装很简单一路next。 下载地址&#xff0c;百度搜“TortoiseGit”&#xff0c;一般是第一个。 目前地址是&#xff1a;https://tortoisegit.org/download/ 如果打不开&#xff0c;可以进入腾讯软件中心…

CF1045G AI robots(动态开点线段树)

题意 火星上有$N$个机器人排成一行&#xff0c;第$i$个机器人的位置为$x_{i}$&#xff0c;视野为$r_{i}$&#xff0c;智商为$q_{i}$。我们认为第$i$个机器人可以看到的位置是$[x_{i}-r_{i},x_{i}r_{i}]$。如果一对机器人相互可以看到&#xff0c;且它们的智商$q_{i}$的差距不大…

android qq登录 获取用户信息吗,免登录 只需要一个QQ号就能获取QQ头像和QQ昵称 获取QQ用户信息API...

[PHP] 纯文本查看 复制代码<?php // headerheader("Content-Type:application/json");error_reporting(E_ALL^E_NOTICE^E_WARNING);// 获取QQ号$qq $_GET["qq"];// 过滤if (trim(empty($qq))) {echo json_encode(array(status > error,msg > 未…

Python3.8安装 jupyter报错 NotImplementedError

报错如下&#xff1a; 原因&#xff1a; 是由于 python3.8 asyncio 在 windows 上默认使用 ProactorEventLoop 造成的&#xff0c;而不是之前的 SelectorEventLoop。jupyter 依赖 tornado&#xff0c;而 tornado 在 window 上需要使用 SelectorEventLoop&#xff0c;所以产生这…

浅析Nginx 正向代理与反向代理

1、正向代理和反向代理的概念 无论是正向代理&#xff0c;还是反向代理&#xff0c;说到底&#xff0c;就是代理模式的衍生版本罢了。我们都学习过代理设计模式&#xff0c;都知道代理模式中有代理角色和被代理角色&#xff0c;为什么这么说&#xff0c;因为这两个角色对于我们…

pycharm 安装 jupyter

jupyter可以像笔记一样&#xff0c;在学习和整理思路时很好。 使用的python是3.7.5版本 windows安装步骤&#xff1a; cmd 再修改下pip的源&#xff0c;选择国内&#xff0c;这样快。 国内pip源: 阿里云 https://mirrors.aliyun.com/pypi/simple/ 广东 豆瓣https://pypi…

android5.1 sdk version,java - Android SDK version 23.6 - Stack Overflow

Does it support java 8 yet?Eclipse is displaying this as a problem, surely it does support 8 by now? In the release notes for revision 23.6 it says java 7 or higher, does this mean java 8 is included or? Wish theyd be more specific about such details. A…

或成为性能宠儿,荣耀8x Max 骁龙660版首销在即

今天已经是十一假期的最后一天了&#xff0c;假期马上就要结束了&#xff0c;虽然这有点让人遗憾&#xff0c;但是接下来的好消息让很多人的心情好了不少&#xff0c;那就是10月8日荣耀8x Max骁龙660版本就要在全平台开售了&#xff0c;这恐怕是节后最开心的事情了。此前&#…

绩效考核编写说明

第一步&#xff1a; 请大家从群文件下载自己的考核表&#xff0c;该表格是季度初填写的&#xff0c;与实际进度安排有偏差&#xff0c;需要调整&#xff08;见第三步&#xff09; 第二步&#xff1a; 请大家从群文件下载部门考核表&#xff0c;如第四季度该文件名“【预评分】…

android 双线程等待,在Java/Android中启动另一个线程之前如何等待线程完成?

在回答您的问题之前&#xff0c;我强烈建议您查看ExecutorServices&#xff0c;例如ThreadPoolExecutor。现在回答你的问题&#xff1a;如果要等待上一个线程完成&#xff0c;在开始下一步之前&#xff0c;您可以在之间添加thread.join()&#xff1a;for(int i 0; i < 10; …

读书笔记-说服力 让你的PPT会说话

说服力&#xff1a;让你的PPT会说话张志 包翔 刘俊前言优秀的幻灯片是内容和形式的完美统一&#xff0c;掌握配色排版特效的技术也很重要&#xff0c;不过对大部分人&#xff0c;这些基础操作都已经初步掌握了。要进一步提高&#xff0c;技术不是制作高水平PPT的主要障碍&#…