YetAnotherForum
Welcome Guest Search | Active Topics | Log In | Register

PI OLEDB AND SSRS Options · View
squatty
#1 Posted : Thursday, August 04, 2011 11:04:46 AM
Rank: Advanced Member

Groups: Member

Joined: 4/7/2011
Posts: 137
Location: KZN, South Africa
I've setup as SQL SERVER REPORT SERVER (SSRS) and I'm in the process of building some rdl report files. The problem I have is the actual query formatting.

A normal query:
SELECT "time", "value" FROM "piarchive".."picalc" WHERE expr = '''TAG1'' + ''TAG2''' and time BETWEEN 't+6h-365d' and 't+6h' AND timestep='1d'

This will extract the last year data and I then need to create a filer in the rdl file in order to get the current month or the selected month based on parameter input.

Required query:
SELECT "time", "value" FROM "piarchive".."picalc" WHERE expr = '''TAG1'' + ''TAG2''' and time BETWEEN ST and ET AND timestep='1d'

I want to use the parameters within the rdl file to specify the start and end times. I don't want to extract a years data and then filter by parameter input, I want to extract only the data i need based on parameter input. Hope this makes sense.
Sponsor  
 

OSIsoft vCampus is a subscription-based, online offering that consists of providing everything people need to develop applications on the PI System.
We invite you to take a "tour" of the OSIsoft Virtual Campus - also feel free to consult the FAQ  or contact OSIsoft vCampus for more details.
squatty
#2 Posted : Friday, April 20, 2012 3:09:47 PM
Rank: Advanced Member

Groups: Member

Joined: 4/7/2011
Posts: 137
Location: KZN, South Africa
Don't you just hate replying to your own post...

SOLVED
I solved the above mentioned by using parameters in the SQL query

SELECT "time", "value" FROM "piarchive".."picalc" WHERE expr = '''TAG1'' + ''TAG2''' and time BETWEEN ? and ? AND timestep='1d'

I then assign default values to these parameters.

NEXT PROBLEM
I need to extract data from multiple tables, but the timestamps of these table are different

The query below will give me the data I need from one table (pirange)
SELECT a.time,a.value as "123",
b.value as "234",
c.value as "345"

FROM piarchive..pirange a

INNER JOIN piarchive..pirange b
ON b.time = a.time
AND b.timestep = a.timestep

INNER JOIN piarchive..pirange c
ON c.time = a.time
AND c.timestep = a.timestep

WHERE a.tag =TAG1'
AND b.tag='TAG2'
AND c.tag='TAG3'

AND a.time BETWEEN '02-jan-2012 06:00' and 't+6h'
AND a.timestep = '1w'
order by a.time desc

PROBLEM

I want to use the same query above but get data from piarchive..pitotal using a different time period (1day extra to be exact)

SELECT a.time,a.value as "123",
b.value as "234",
c.value as "345",
d.value as "456"

FROM piarchive..pirange a

INNER JOIN piarchive..pirange b
ON b.time = a.time
AND b.timestep = a.timestep

INNER JOIN piarchive..pirange c
ON c.time = a.time
AND c.timestep = a.timestep

INNER JOIN piarchive..pitotal d
ON d.time BETWEEN '03-jan-2012 06:00' and 't+6h' --ALL KINDS OF HELL BROKE LOOSE FROM HERE
--AND d.timestep = a.timestep

WHERE a.tag ='TAG1'
AND b.tag='TAG2'
AND c.tag='TAG3'
AND d.tag='NEWTAG'

AND a.time BETWEEN '02-jan-2012 06:00' and 't+6h'
--AND d.time BETWEEN '03-jan-2012 06:00' and 't+6h'
--AND d.calcbasis = 'EventWeighted'
AND a.timestep = '1w'
order by a.time desc
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.