复杂SQL

一行多个人员,平均瓜分总产量。

-- 西宁硅料三期
with b as (
select(row_number() OVER(PARTITION BY t1.tool ORDER BY t1.tool ) - 1) AS help_topic_id
from((select1 AS tool
union allselect1 AS tool
union allselect1 AS tool
union allselect1 AS tool) t1
join (select1 AS tool
union allselect1 AS tool
union allselect1 AS tool
union allselect1 AS tool
union allselect1 AS tool) t2)),
tmp as (
selecta.id AS id,a.widget_456031860032536576 AS date_time,gg.gx AS gx,b.widget_453948803158900736 AS gy,a.widget_456031860032536580 AS dj,a.widget_456031860032536584 AS weight,regexp_replace(if((a.widget_456031860032536582 = '[]'), concat_ws(',', a.user_laowu1, a.user_laowu2, a.lwname3, a.lwname4, a.lwname5), concat_ws(',', a.widget_456031860032536582, a.user_laowu1, a.user_laowu2, a.lwname3, a.lwname4, a.lwname5)), '\\[|\\]|"', '') AS arr_person,a.creation_date AS tp,a.widget_456031860032536583 AS pc
from((xdap_app_339816648452079617.view_456031859625689088 a
left join xdap_app_339816648452079617.view_453948802894659584 b on((replace(replace(a.widget_456031860032536579, '["', ''), '"]', '') = b.id)))
left join xdap_app_339816648452079617.glcl_gx gg on((replace(replace(a.widget_456031860032536578, '["', ''), '"]', '') = gg.id)))
WHERE a.widget_456031860032536576 >= DATE_SUB(DATE_FORMAT(NOW(), '%Y-%m-01 08:30:00'), INTERVAL 1 MONTH) and a.widget_456031860032536576 < DATE_FORMAT(NOW(), '%Y-%m-01 08:30:00')
),
tmp_2 as (
selecttmp.id AS id,tmp.date_time AS date_time,tmp.gx AS gx,tmp.gy AS gy,tmp.dj AS dj,tmp.weight AS weight,tmp.arr_person AS arr_person,substring_index(substring_index(tmp.arr_person, ',',(b.help_topic_id + 1)), ',',-(1)) AS exp_person,tmp.tp AS tp,tmp.pc as pc
from(tmp
join b)
where(b.help_topic_id < ((length(tmp.arr_person) - length(replace(tmp.arr_person, ',', ''))) + 1))
),
tmp_3 as (
selecttmp_2.id AS id,count(distinct tmp_2.exp_person) AS person_cnt
fromtmp_2
group bytmp_2.id
),
final as (
selectt1.id AS id,t1.date_time AS date_time,t1.gx AS gx,t1.gy AS gy,t1.dj AS dj,t1.weight AS weight,t1.arr_person AS arr_person,t1.exp_person AS exp_person,t2.person_cnt AS person_cnt,TRUNCATE(t1.weight / t2.person_cnt, 2) AS yield,t1.tp AS tp,t1.pc AS pc
from(tmp_2 t1
left join tmp_3 t2 on((t1.id = t2.id)))
)
selectREPLACE(UUID() , '-', '') as bi_id,'西宁' as bi_base,'三期' as bi_period,'硅料' as bi_type,t1.gx AS bi_gx,t1.gy AS bi_gy,t1.dj AS bi_dj,t2.user_number AS bi_gh,ifnull(t2.username, t1.exp_person) AS bi_xm,t1.yield AS bi_yield,t1.tp AS date_time,CONCAT('批次: ',t1.pc) AS bi_remark,t1.date_time AS bi_datetime,DATE_FORMAT(DATE_SUB(NOW(), INTERVAL 1 MONTH), '%Y-%m') as bi_month
from(final t1
left join xdap_app_339816648452079617.xdap_users t2 on((t1.exp_person = t2.id)))

西宁硅料二期

with b as (
select(row_number() OVER(PARTITION BY t1.tool ORDER BY t1.tool)-1) AS help_topic_id
from((select1 AS tool
union allselect1 AS tool
union allselect1 AS tool
union allselect1 AS tool) t1
join (select1 AS tool
union allselect1 AS tool
union allselect1 AS tool
union allselect1 AS tool
union allselect1 AS tool) t2)
),
tmp as (
selecta.id AS id,a.widget_446956575546933248 AS date_time,gg.gx AS gx,b.widget_453948803158900736 AS gy,a.widget_453973982488559617 AS dj,a.widget_446956575546933254 AS weight,regexp_replace(if(((a.widget_446956575546933252 is null) or (a.widget_446956575546933252 = '[]')), concat_ws(',', a.widget_555350966648438784, a.widget_555350966648438785, a.widget_596761283412361216, a.widget_596761283412361217, a.widget_596761283412361218), concat_ws(',', a.widget_446956575546933252, a.widget_555350966648438784, a.widget_555350966648438785, a.widget_596761283412361216, a.widget_596761283412361217, a.widget_596761283412361218)), '\\[|\\]|"', '') AS arr_person,a.creation_date AS tp,a.widget_446956575546933253 AS pc
from((xdap_app_339816648452079617.view_446956575110725632 a
left join xdap_app_339816648452079617.view_453948802894659584 b on((replace(replace(a.widget_453973982488559616, '["', ''), '"]', '') = b.id)))
left join xdap_app_339816648452079617.glcl_gx gg on((replace(replace(a.widget_454284003264954368, '["', ''), '"]', '') = gg.id)))
WHERE a.widget_446956575546933248 >= DATE_SUB(DATE_FORMAT(NOW(), '%Y-%m-01 08:30:00'), INTERVAL 1 MONTH) and a.widget_446956575546933248 < DATE_FORMAT(NOW(), '%Y-%m-01 08:30:00')
),
tmp_2 as (
selecttmp.id AS id,tmp.date_time AS date_time,tmp.gx AS gx,tmp.gy AS gy,tmp.dj AS dj,tmp.weight AS weight,tmp.arr_person AS arr_person,substring_index(substring_index(tmp.arr_person, ',',(b.help_topic_id + 1)), ',',-(1)) AS exp_person,tmp.tp AS tp,tmp.pc AS pc
from(tmp
join b)
where(b.help_topic_id < ((length(tmp.arr_person) - length(replace(tmp.arr_person, ',', ''))) + 1))
),
tmp_3 as (
selecttmp_2.id AS id,count(distinct tmp_2.exp_person) AS person_cnt
fromtmp_2
group bytmp_2.id
),
final as (
selectt1.id AS id,t1.date_time AS date_time,t1.gx AS gx,t1.gy AS gy,t1.dj AS dj,t1.arr_person AS arr_person,t1.exp_person AS exp_person,t2.person_cnt AS person_cnt,TRUNCATE(t1.weight / t2.person_cnt, 2) AS yield,t1.tp AS tp,t1.pc AS pc
from(tmp_2 t1
left join tmp_3 t2 on((t1.id = t2.id)))
)
selectREPLACE(UUID() , '-', '') as bi_id,'西宁' as bi_base,'二期' as bi_period,'硅料' as bi_type,t1.gx AS bi_gx,t1.gy AS bi_gy,t1.dj AS bi_dj,t2.user_number AS bi_gh,ifnull(t2.username, t1.exp_person) AS bi_xm,t1.yield AS bi_yield,t1.tp AS date_time,CONCAT('批次: ', t1.pc) AS bi_remark,t1.date_time AS bi_datetime,DATE_FORMAT(DATE_SUB(NOW(), INTERVAL 1 MONTH), '%Y-%m') as bi_month
from(final t1
left join xdap_app_339816648452079617.xdap_users t2 on((t1.exp_person = t2.id)))

西宁硅料一期

with b as (
select(row_number() OVER(PARTITION BY t1.tool ORDER BY t1.tool) - 1) AS help_topic_id
from((select1 AS tool
union allselect1 AS tool
union allselect1 AS tool
union allselect1 AS tool) t1
join (select1 AS tool
union allselect1 AS tool
union allselect1 AS tool
union allselect1 AS tool
union allselect1 AS tool) t2)
),
tmp as (
selecta.id AS id,a.widget_438304971969003520 AS date_time,gg.gx AS gx,b.widget_453948803158900736 AS gy,a.widget_453888051886686208 AS dj,a.widget_445894624578371584 AS weight,regexp_replace(if((a.widget_443337882443186176 = '[]'),regexp_replace(concat_ws(',', a.widget_535134057806168064, a.widget_535135291673935872, a.widget_538021294705213440, a.widget_538021294705213441, a.widget_538021294705213442), '\\[|\\]|"', ''),concat_ws(',', a.widget_443337882443186176, a.widget_535134057806168064, a.widget_535135291673935872, a.widget_538021294705213440, a.widget_538021294705213441, a.widget_538021294705213442)), '\\[|\\]|"', '') AS arr_person,a.widget_445891041954889728 AS pc,a.creation_date AS tp
fromxdap_app_339816648452079617.view_438304971734122496 a
left join xdap_app_339816648452079617.view_453948802894659584 b onreplace(replace(a.widget_453960078530183168, '["', ''), '"]', '') = b.id
left join xdap_app_339816648452079617.glcl_gx gg onreplace(replace(a.widget_454231553468268544, '["', ''), '"]', '') = gg.id
WHERE a.widget_438304971969003520 >= DATE_SUB(DATE_FORMAT(NOW(), '%Y-%m-01 08:30:00'), INTERVAL 1 MONTH) and a.widget_438304971969003520 < DATE_FORMAT(NOW(), '%Y-%m-01 08:30:00')
),
tmp_2 as (
selecttmp.id AS id,tmp.date_time AS date_time,tmp.gx AS gx,tmp.gy AS gy,tmp.dj AS dj,tmp.weight AS weight,tmp.arr_person AS arr_person,substring_index(substring_index(tmp.arr_person, ',',(b.help_topic_id + 1)), ',',-(1)) AS exp_person,tmp.pc AS pc,tmp.tp AS tp
from
(tmp
join b)
where(b.help_topic_id < ((length(tmp.arr_person) - length(replace(tmp.arr_person, ',', ''))) + 1))
),
tmp_3 as (
selecttmp_2.id AS id,count(distinct tmp_2.exp_person) AS person_cnt
fromtmp_2
group bytmp_2.id
),
final as (
selectt1.id AS id,t1.date_time AS date_time,t1.gx AS gx,t1.gy AS gy,t1.dj AS dj,t1.weight AS weight,t1.arr_person AS arr_person,t1.exp_person AS exp_person,t2.person_cnt AS person_cnt,TRUNCATE(t1.weight / t2.person_cnt, 2) AS yield,t1.pc as pc,t1.tp AS tp
fromtmp_2 t1
left join tmp_3 t2 ont1.id = t2.id
)
selectREPLACE(UUID() , '-', '') as bi_id,'西宁' as bi_base,'一期' as bi_period,'硅料' as bi_type,t1.date_time AS bi_datetime,t1.gx AS bi_gx,t1.gy AS bi_gy,t1.dj AS bi_dj,t1.weight AS weight,t2.user_number AS bi_gh,ifnull(t2.username, t1.exp_person) AS bi_xm,t1.yield AS bi_yield,CONCAT('批次: ',t1.pc) AS bi_remark,t1.tp AS date_time,DATE_FORMAT(DATE_SUB(NOW(), INTERVAL 1 MONTH), '%Y-%m') as bi_month
fromfinal t1
left join xdap_app_339816648452079617.xdap_users t2 ont1.exp_person = t2.id

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

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

相关文章

bin log 和 redo log有什么区别

问题bin log 和 redo log有什么区别我的回答首先&#xff0c;这两种日志的作用不同。redo log是InnoDB引擎特有的&#xff0c;主要用于崩溃恢复&#xff0c;保证事务的持久性。而bin log是MySQL服务层的日志&#xff0c;主要用于主从复制和数据恢复。从层次上看&#xff0c;red…

导入文件允许合并表格

本来呢&#xff0c;已经有几年没咋写博客了&#xff0c;但是好像网上没什么好的合并导入可以抄的&#xff0c;周末加班了一天弄出来了&#xff0c;想一想也不算造轮子&#xff0c;可以露一手出来&#xff0c;最近也挺喜欢写注释的&#xff0c;应该方便大家抄的public class Tra…

WebIDEPLOY 技术驱动樱桃溯源管理系统的价值重塑与落地实践—— 以樱桃溯源管理系统构建产业信任体系的路径探索

一、WebIDEPLOY 技术支撑下的樱桃溯源系统核心架构樱桃种植从开花到销售的全流程数据记录&#xff0c;需要兼顾专业性与易操作性&#xff0c;WebIDEPLOY 技术以 “零代码降低门槛、云原生优化成本” 的特性&#xff0c;成为连接数字工具与樱桃种植的关键纽带。系统核心架构围绕…

零知开源——基于STM32F407VET6实现ULN2003AN驱动28BYJ-48步进电机控制系统

✔零知IDE 是一个真正属于国人自己的开源软件平台&#xff0c;在开发效率上超越了Arduino平台并且更加容易上手&#xff0c;大大降低了开发难度。零知开源在软件方面提供了完整的学习教程和丰富示例代码&#xff0c;让不懂程序的工程师也能非常轻而易举的搭建电路来创作产品&am…

如何多个手机设备的实现不同公网IP

为了避免多个手机设备使用相同的公网IP地址导致平台检测关联&#xff0c;可以通过以下方法实现不同公网IP的分配和管理. 一、移动网络&#xff08;SIM 卡&#xff09;方案 1.移动数据与Wi-Fi切换&#xff1a;通过切换移动数据和不同Wi-Fi网络&#xff08;如家庭Wi-Fi、公共Wi-F…

沙箱操作指南

这是一份通用且详细的沙箱操作指南。沙箱(Sandbox)是一种安全隔离环境,常用于测试未经验证的代码、软件、文件或访问可疑网址,而不会对真实系统造成危害。 本指南将分为以下几个部分: 沙箱是什么? 为什么需要使用沙箱? 如何使用沙箱?(三种主要类型) 最佳实践与注意事…

【数字IC后端】引导时钟树CTS的生成方向之anchor driver

如何控制数字IC后端CTS的生成方向&#xff1f;我们可以引入anchor driver来实现引导。景芯12nm车规APR实战中&#xff0c;我们可以看到&#xff0c;绝大部分的sink都受控于xxxx_tessent_occ_clk_cpu_inst/tessent_persistent_cell_clock_out_mux/C10_ctmi_1这个mux&#xff0c;…

「Java EE开发指南」如何使用MyEclipse启用自动JSP验证?

自动JSP验证可以在两种情况下启用&#xff0c;在本文中您将学习如何正确使用它。 该特性在MyEclipse中可用。 MyEclipse v2025.1离线版下载 您可以在保存JSP编辑器的内容或执行“Clean”操作时启用自动JSP验证。要进行正确的验证&#xff0c;必须使用完整的JDK JVM启动MyEcl…

leetcode_73 矩阵置零

1. 题意 给定一个 m x n 的矩阵&#xff0c;如果一个元素为 0 &#xff0c;则将其所在行和列的所有元素都设为 0 。请使用 原地 算法。 2. 题解 想不到O(1)的空间复杂度的做法&#xff0c; 只有抄抄题解这样子才能维持的了生活。 2.1 暴力 维护两个标记数组&#xff0c;分…

优雅地实现ChatGPT式的打字机效果:Spring Boot 流式响应

01 引言 之前专门介绍过流式响应的数据的接收、发送以及使用SSE由服务端推送数据的文章&#xff0c;但是要求前端必须使用EventSource订阅实现。 有没有通过直接通过浏览器访问或者Fetch API直接调用的方式呢&#xff1f;效果还能和ChatGPT一样&#xff0c;实现打字机的效果呢&…

Git 删除文件

在 Git 中&#xff0c;删除文件同样被视为一种修改操作。下面我们通过实际操作演示如何删除文件。假设要删除文件 file5&#xff0c;如果你直接在文件系统中执行了删除&#xff1a;这种直接删除的方式并不会在 Git 中生效&#xff0c;反而会导致工作区与版本库不一致。使用 git…

虚幻基础:角色变换角色视角蒙太奇运动

能帮到你的话&#xff0c;就给个赞吧 &#x1f618; 文章目录角色视角机臂使用pawn控制旋转&#xff1a;旋转体将失去作用旋转体摄像机&#xff1a;可以使用旋转体控制&#xff1a;pawn不起作用角色变换角色移动&#xff1a;由移动组件控制移动方向&#xff1a;给组件任意一个方…

【LeetCode】31. 下一个排列

文章目录31. 下一个排列题目描述示例 1&#xff1a;示例 2&#xff1a;示例 3&#xff1a;提示&#xff1a;解题思路1. 问题本质与字典序回顾2. 经典算法三步曲&#xff08;必须原地、常数空间&#xff09;3. 直观示例与过程可视化4. 与“62. 不同路径”风格对应的分析维度4.1 …

CVPR2025丨VL2Lite:如何将巨型VLM的“知识”精炼后灌入轻量网络?这项蒸馏技术实现了任务专用的极致压缩

关注gongzhonghao【CVPR顶会精选】小模型&#xff08;Small Models&#xff09;通常指参数量较小、计算与存储成本更低的深度学习模型。近年来&#xff0c;它们在移动端部署、边缘计算和隐私保护等场景中快速发展&#xff0c;逐渐成为大模型的轻量化补充。随着蒸馏、剪枝、量化…

【SystemUI】锁屏来通知默认亮屏Wake模式

一、问题描述 基于 Android 14平台&#xff0c;锁屏状态下来通知时默认是进入Doze模式&#xff0c;此时屏幕不能点击只能查看通知信息且很快灭屏&#xff0c;用户体验不是很好&#xff0c;要求修改为通知直接亮屏。二、问题分析 梳理锁屏状态下&#xff08;特指设备息屏或处于D…

高并发写入、毫秒级查询——盘古信息携手 TDengine 时序数据库解决六大技术挑战

小T导读&#xff1a;广东盘古信息科技股份有限公司&#xff08;下文简称盘古信息&#xff09;成立于 2005 年&#xff0c;是一家基于工业互联网平台的数字化管理解决方案供应商&#xff0c;公司自主研发的 IMS&#xff08;数字化智能制造系统&#xff09;可为离散、流程及混合制…

Unity 打包 iOS,Xcode 构建并上传 App Store

一、准备工作&#xff08;环境、账号、证书与项目基础&#xff09;系统与工具macOS&#xff1a;使用与最新 Xcode 兼容的版本。Xcode&#xff1a;从 Mac App Store 安装最新稳定版&#xff08;建议与当前 App Store 必需的 Xcode 主版本保持一致&#xff09;。Unity&#xff1a…

Windows系统安装stata软件教程

1、解压缩2、点击next3、选择第一个&#xff0c;然后next4、这里随便填写就行5、选择stataMP&#xff0c;然后next6、这里改个路径&#xff0c;例如D:\Program Files\Stata18\7、这里不用管&#xff0c;选择next8、点击install&#xff0c;开始安装过程9、安装过程展示。10、最…

Android 开发 - 数据共享(数据共享、内容提供者实现、动态权限申请)

一、数据共享 1、内容提供者 内容提供者 ContentProvider 为 APP 存取内部数据提供统一的外部接口&#xff0c;让不同的应用之间得以共享数据2、流程理解 Client APP 将用户的输入内容通过 ContentProvider 跨进程通信传递给 Server APP3、数据访问 利用 ContentProvider 只实现…

【51单片机按键按下数码管秒增计时并LED亮释放停计时LED熄】2022-11-12

缘由单片机控制数码管及LED灯-嵌入式-CSDN问答 #include "REG52.h" sbit k1P3^0; unsigned char Js0;//计时 unsigned char code smgduan[]{0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07 ,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71,0,64,15,56}; //共阴0~F消隐减号 void…