Ignition Postgresql语句查询

时间戳转换
select *,to_timestamp(t_stamp/1000) as t_stampNew from sqlt_data_2_2021_11 order by  t_stamp
select d.tagid,d.floatvalue,to_timestamp(d.t_stamp/1000) as t_stamp,d.dataintegrity  
, t.id,t.tagpath,t.created,t.retired from sqlt_data_3_2020_06 as d,sqlth_te as t 
where d.tagid=t.id and t.id=880
order by t_stamp desc  limit 100
联合多个历史数据表查询
SELECT tagid, intvalue, floatvalue, stringvalue, datevalue, dataintegrity, t_stamp,to_timestamp(t_stamp/1000) as new_t_stamp
FROM (
    SELECT * FROM public.sqlt_data_1_2023_01
    UNION ALL
    SELECT * FROM public.sqlt_data_1_2023_02
  
) AS combined_data where tagid=109
范围查询 tagid in
select d.tagid,d.floatvalue,to_timestamp(d.t_stamp/1000) as t_stamp,d.dataintegrity , t.id,t.tagpath,t.created,t.retired from sqlt_data_3_2021_04 as d,sqlth_te as t where d.tagid=t.id and tagid in (7662,6964) order by t_stamp desc limit 1000
根据tagpath查询历史数据
select d.tagid,d.floatvalue,to_timestamp(d.t_stamp/1000) as t_stamp,d.dataintegrity , t.id,t.tagpath,t.created,t.retired from sqlt_data_3_2021_04 as d,sqlth_te as t where d.tagid= t.id and tagpath = 'item1/sensors/edtlit0201/sensorstatus/value' order by t_stamp desc limit 50000
select to_timestamp(d.t_stamp/1000) as t_stamp,d.floatvalue as upData from sqlt_data_3_2021_04 as d,sqlth_te as t 
where d.tagid=t.id and tagpath='item1/sensors/edtlit0201/sensorstatus/value' 
order by t_stamp desc  limit 1000
select to_timestamp(d.t_stamp/1000) as t_stamp,d.floatvalue as data1 from sqlt_data_3_2021_04 as d,sqlth_te as t 
where d.tagid=t.id and tagpath='item1/sensors/edtlit0201/sensorstatus/value' and to_timestamp(t_stamp/1000)>'2021-04-19 17:56:34 ' and to_timestamp(t_stamp/1000)< ' 2021-04-19 17:56:34  ' order by t_stamp desc
查询记录个数
select t.tagpath ,d.tagid, count(*) cnt from sqlt_data_1_2022_09 as d ,sqlth_te as t  where d.tagid=t.id  group by d.tagid,t.tagpath order by cnt desc;
factor表

postgres数据库

sql ='''SELECT id, "pName", "pN", "pLevel", f1, f2, f3, "qcDate", "qcNo", "qcPeople" FROM public.qc;'''
table = system.db.runQuery(sql)
event.source.parent.getComponent('Chart').InputData=table

sqltie数据库

SELECT datetime(qcDate/1000, 'unixepoch', 'localtime')as qcDate from qc
删除记录,ID从1开始

子增加字段从1开始,但是会删除所有
TRUNCATE qc_factor RESTART IDENTITY;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

淡水瑜

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值