mysql timestamp

Wesley13
• 阅读 533

 select from_unixtime(m.createdAt, '%Y-%m-%d %H:%i:%s') from kfrobotaidlog m;

select m.customeruid, from_unixtime(m.createtime, '%Y-%m-%d %H:%i:%s') as `date-time`, m.kfuid,
case when m.kfuid = 1001 then '自动回答' when type = 2  then '人工回答'  else '客户问题' end as `问答`, 
m.content as `内容` from kfmessage m
join (select distinct customeruid from kfmessage where kfuid = 1001 
and 

createtime >=  
UNIX_TIMESTAMP(STR_TO_DATE('2019-01-20 00:00:00', '%Y-%m-%d %H:%i:%s')) AND 
UNIX_TIMESTAMP(STR_TO_DATE('2019-01-20 07:00:00', '%Y-%m-%d %H:%i:%s'))) 

m2 on m.customeruid = m2.customeruid
where 
m.createtime > UNIX_TIMESTAMP(STR_TO_DATE('2019-01-20 00:00:00', '%Y-%m-%d %H:%i:%s')) 
and 
m.createtime < UNIX_TIMESTAMP(STR_TO_DATE('2019-01-20 10:00:00', '%Y-%m-%d %H:%i:%s')) 
and
m.kfuid <> 1002
order by m.customeruid, id 

=======================波哥查询=========================

查看customeruid

select m.customeruid, m.content, a.clientQuestion, a.answer from kfrobotaidlog a join kfmessage m on a.messageId = m.id group by m.customeruid

=================

分析智能客服对话

 select from_unixtime(m.createdAt, '%Y-%m-%d %H:%i:%s') from kfrobotaidlog m;

select m.customeruid, from_unixtime(m.createtime, '%Y-%m-%d %H:%i:%s') as `date-time`, m.kfuid,
case when m.kfuid = 1001 then '自动回答' when type = 2  then '人工回答'  else '客户问题' end as `问答`, 
m.content as `内容` from kfmessage m
join (select distinct customeruid from kfmessage where kfuid = 1001 
and 

createtime >=  
UNIX_TIMESTAMP(STR_TO_DATE('2019-01-20 00:00:00', '%Y-%m-%d %H:%i:%s')) AND 
UNIX_TIMESTAMP(STR_TO_DATE('2019-01-20 07:00:00', '%Y-%m-%d %H:%i:%s'))) 

m2 on m.customeruid = m2.customeruid
where 
m.createtime > UNIX_TIMESTAMP(STR_TO_DATE('2019-01-20 00:00:00', '%Y-%m-%d %H:%i:%s')) 
and 
m.createtime < UNIX_TIMESTAMP(STR_TO_DATE('2019-01-20 10:00:00', '%Y-%m-%d %H:%i:%s')) 
and
m.kfuid <> 1002
order by m.customeruid, id 

 ====================

查找某一天接入的人的数量

select * from
(select m.customeruid, m.content, a.clientQuestion, a.answer,a.questionUid,from_unixtime(a.createdAt, '%Y-%m-%d %H:%i:%s') as createtime from kfrobotaidlog a join kfmessage m on a.messageId = m.id ) t
where createtime> '2019-01-31 00:17:09' and createtime< '2019-02-01 00:17:09'

点赞
收藏
评论区
推荐文章
blmius blmius
2年前
MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1
文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s
Stella981 Stella981
2年前
AndroidStudio封装SDK的那些事
<divclass"markdown\_views"<!flowchart箭头图标勿删<svgxmlns"http://www.w3.org/2000/svg"style"display:none;"<pathstrokelinecap"round"d"M5,00,2.55,5z"id"raphael
Wesley13 Wesley13
2年前
mysql简单常用语句汇总
1\.常用函数uuid和时间戳SELECTUUID(),UNIX_TIMESTAMP();将时间戳转为日期格式FROM_UNIXTIME(mw.created_at,'%Y%m%d%H:%i:%s')设置参数select@m_no:max(m_no)fromvc_m;set@m
Stella981 Stella981
2年前
Python之time模块的时间戳、时间字符串格式化与转换
Python处理时间和时间戳的内置模块就有time,和datetime两个,本文先说time模块。关于时间戳的几个概念时间戳,根据1970年1月1日00:00:00开始按秒计算的偏移量。时间元组(struct_time),包含9个元素。 time.struct_time(tm_y
Wesley13 Wesley13
2年前
mysql设置时区
mysql设置时区mysql\_query("SETtime\_zone'8:00'")ordie('时区设置失败,请联系管理员!');中国在东8区所以加8方法二:selectcount(user\_id)asdevice,CONVERT\_TZ(FROM\_UNIXTIME(reg\_time),'08:00','0
Stella981 Stella981
2年前
HIVE 时间操作函数
日期函数UNIX时间戳转日期函数: from\_unixtime语法:   from\_unixtime(bigint unixtime\, string format\)返回值: string说明: 转化UNIX时间戳(从19700101 00:00:00 UTC到指定时间的秒数)到当前时区的时间格式举例:hive   selec
Stella981 Stella981
2年前
Python time模块 返回格式化时间
常用命令  strftimetime.strftime("%Y%m%d%H:%M:%S",formattime)第二个参数为可选参数,不填第二个参数则返回格式化后的当前时间日期201812112:00:00time.strftime('%H:%M:%S')返回当前时间的时分秒time.strftim
Wesley13 Wesley13
2年前
mysql统计
时间转任意格式DATE_FORMATselectDATE_FORMAT(NOW(),'%m%d%Y');unix_timestamp时间转时间戳selectunix_timestamp(now());from_unixtime时间戳转时间
Stella981 Stella981
2年前
Android蓝牙连接汽车OBD设备
//设备连接public class BluetoothConnect implements Runnable {    private static final UUID CONNECT_UUID  UUID.fromString("0000110100001000800000805F9B34FB");
Python进阶者 Python进阶者
3个月前
Excel中这日期老是出来00:00:00,怎么用Pandas把这个去除
大家好,我是皮皮。一、前言前几天在Python白银交流群【上海新年人】问了一个Pandas数据筛选的问题。问题如下:这日期老是出来00:00:00,怎么把这个去除。二、实现过程后来【论草莓如何成为冻干莓】给了一个思路和代码如下:pd.toexcel之前把这