-
-
18754176079 数据达人Lv4
发表于2022-8-4 11:27
悬赏1
未解决
楼主
select concat('{', GROUP_CONCAT( concat('"',a1.PN,'":"', a1.value,'"')), '}') as his_value from (select opc.customer_id, opc.device_id, opc.PN, opc.time, opc.value,opc.event_day,row_number() over (PARTITION BY opc.pn order by opc.time desc) rowindex from opc_ts_data as opc where opc.customer_id = 'lvliang' and opc.device_id = 'V4.Device1' and (opc.time > DATE_ADD('2022-03-08 00:00:00', INTERVAL -35 second) and opc.time <='2022-03-08 00:00:00') order by time) as a1 where a1.rowindex=1
[size=13.0667px]select concat('{', GROUP_CONCAT( concat('"',a1.PN,'":"', a1.value,'"')), '}') as his_valuefrom (selectopc.customer_id, opc.device_id, opc.PN, opc.time, opc.value,opc.event_day,row_number() over (PARTITION BY opc.pn order by opc.time desc) rowindexfromopc_ts_data as opcwhereopc.customer_id = 'lvliang'and opc.device_id = 'V4.Device1'and (opc.time > DATE_ADD('<#=@his_current_time#>', INTERVAL -35 second) and opc.time <='<#=@his_current_time#>')order by time) as a1 where a1.rowindex=1我想把页面在初次计算为宏表达式放一个默认值,后续根据时间的不同再动态修改时间,请问有什么方法可以实现(因为库中数据量比较大,如果宏表达式为空在初次计算时会拖慢查询速度)
[size=13.0667px]select concat('{', GROUP_CONCAT( concat('"',a1.PN,'":"', a1.value,'"')), '}') as his_valuefrom (selectopc.customer_id, opc.device_id, opc.PN, opc.time, opc.value,opc.event_day,row_number() over (PARTITION BY opc.pn order by opc.time desc) rowindexfromopc_ts_data as opcwhereopc.customer_id = 'lvliang'and opc.device_id = 'V4.Device1'and (opc.time > DATE_ADD('<#=@his_current_time#>', INTERVAL -35 second) and opc.time <='<#=@his_current_time#>')order by time) as a1 where a1.rowindex=1我想把页面在初次计算为宏表达式放一个默认值,后续根据时间的不同再动态修改时间,请问有什么方法可以实现(因为库中数据量比较大,如果宏表达式为空在初次计算时会拖慢查询速度)
4个回答
-
18754176079 数据达人Lv4
板凳
小怪兽 发表于 2022-8-4 14:45
您这边是在使用sql主题表嘛,编辑sql主题表的地方可以设置参数的默认值
我设置了默认值如果要变更宏变量的时候会变化嘛