home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.databases.ms-sqlserver      Notorious Rube Goldberg contraption      19,505 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 18,060 of 19,505   
   Bob Barrows to mcolson   
   Re: Pivot table from Historian Data   
   07 Jan 11 14:59:29   
   
   0f5d0e92   
   From: reb01501@NOSPAMyahoo.com   
      
   mcolson wrote:   
   > I have data that has been captured in historian.  I'm trying to create   
   > a view that displays data captured via a Historian in a Pivot Table.   
   > I'm having trouble with using the PIVOT operator.  Any help on how   
   > this could be turned into a pivot table?   
   >   
   > SELECT     DateTime, TagName, Value AS Pressure   
   > FROM         History   
   > WHERE     (DateTime >= CONVERT(DATETIME, '2010-12-22 00:00:00', 102))   
   > AND (TagName IN ('Rough', 'HiVac1', 'Leg1', 'Leg2')   
   >   
   > 'What I get   
   > 2010/12/23 Rough 2.100   
   > 2010/12/23 HiVac1 1433.59   
   > 2010/12/23 Leg1 1536   
   > 2010/12/23 Leg2 0.40   
   > 2010/12/24 Rough 2.100   
   > 2010/12/24 HiVac1 3276.80   
   > 2010/12/24 Leg1 3379   
   > 2010/12/24 Leg2 2.10   
   >   
   > 'What I'm trying to get   
   >         Rough HiVac1 Leg1 Leg2   
   > 2010/12/23 2.100 1433.59 1536 0.40   
   > 2010/12/24 2.100 3276.80 3379 2.10   
   >   
   > Thanks in advance for any help.   
      
   What version of SQL Server? If pre-2005, google for SQL pivot. If 2005+.   
   look for the pivot topics in SQL BOL (Books Online)   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca