hr的sql

客户朋友圈统计

select m.moment_id as '任务id',
m.create_time_time as '创建时间',
m.creator as '创建人',
m.text_content as '文本内容',
m.create_type as '创建来源 0企业 1个人',
m.visible_type as '可见范围 0部分可见 1公开',
m.ucount as '员工总数1',
-- (n.ucount +f.ucount) as '员工总数', 
n.ucount as '未发表人数',
f.ucount as '已发表人数',
cc.ccount as '评论数',
cl.clount as '点赞数'  from  (
select m.moment_id,m.create_time_time,
m.creator,m.create_type,m.visible_type,m.text_content,
count(t.userid) as  ucount
from wecome_moment_list  m 
left join wecome_moment_task t on m.moment_id=t.moment_id 
where 1=1
-- m.create_type='0' 
-- and  m.link_title='富安娜艺术家' 
-- and m.create_time_time >='2023-09-21 00:00:00'
-- and m.creator = 34236 
-- and m.moment_id='mom0z2ajBwAAG0mNArdX_fWGiT4ZkdWImw'
GROUP BY m.moment_id,m.create_time_time,
m.creator,m.create_type,m.visible_type,m.text_content  
order by m.create_time_time desc) m

left join 
(
select m.moment_id,count(t.userid) as  ucount
from wecome_moment_list  m  
left join wecome_moment_task t on m.moment_id=t.moment_id
where  t.publish_status ='0'
GROUP BY m.moment_id ) as n  on n.moment_id = m.moment_id

left join 
(
select m.moment_id,count(t.userid) as  ucount
from wecome_moment_list  m  
left join wecome_moment_task t on m.moment_id=t.moment_id
where t.publish_status ='1'
GROUP BY m.moment_id ) as f on f.moment_id = m.moment_id

left join 
(SELECT moment_id,count(id) as ccount  from  wecome_moment_comments  where comment_type ='comment'
GROUP BY  moment_id ) cc on cc.moment_id = m.moment_id
left join 
(SELECT moment_id,count(id) as clount from  wecome_moment_comments  where comment_type ='like'
GROUP BY  moment_id) cl on cl.moment_id = m.moment_id
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值