AnsweredAssumed Answered

Convert PICalclVal in SQL ?

Question asked by xla99 on Aug 22, 2017
Latest reply on Aug 23, 2017 by sraposo



I'm working on a client application that needs to collect data from a PI database.

The users are currently using Excel but we want to directly connect to the database through SQL.

I've started to work with PIOLEDB since this morning and I'm not able to reproduce my Excel results in SQL.

Here is an Excel example where I get daily production results thanks to the PIClacVal function (tonnes per day):


I translated it in that simple SQL query :

SELECT tag, time, value

FROM [piarchive]..[pitotal]

WHERE tag = 'Drg_production' AND time BETWEEN '2016-12-02 00:00' AND '2016-12-06 00:00' AND timestep = '24h'


Which returns something completely different :

Please help, what is wrong with my query ? I understood that pitotal is supposed to return totals based on a time step but it looks that I'm missing something.