I am trying to create a view for Windows Performance Monitors. The issue I have is that Table I have called "AllPerf" has 2 of the columns called "PerfCounter" and "Application" have several different names of Performance counters and Applications in them.
Ideally, what I want for my columns is: Time, Computer, Application name, and then the names of all the PerfCounter rows into columns.
I created a view of only the row names I want, and with the current view I created below, I get this output:
-----------------------------------------------------------------------
| mem.AlertTime       | Computer | PerfCounter | Application | Value  |
-----------------------------------------------------------------------
| 2019-03-15 14:49:02 | WEB-04   | Vrt_Bytes   | System      |0.1368  |
| 2019-03-15 14:49:02 | WEB-05   | Vrt_Bytes   | System      |2440    |
| 2019-03-15 14:49:02 | WEB-06   | Handles     | w3wp        |1508    |
| 2019-03-15 14:49:02 | WEB-04   | Page_Faults | System      |0.00419 |
| 2019-03-15 14:49:02 | WEB-04   | Prvt_Bytes  | System      |0.1368  |
-----------------------------------------------------------------------
I've tried the solutions in this link below, but when I can successfully list row names as columns, I get no Values populated under the columns. Efficiently convert rows to columns in sql server
And since I don't have much experience with SQL in general, I can't seem to extrapolate the simple examples with my more complex data
This is what i'm using for my SELECT statement for my current view.
SELECT  mem.AlertTime, 
    Computer, 
        CASE WHEN mem.PerfCounter = 'Virtual Bytes' THEN 'Virt_Bytes' 
    WHEN mem.PerfCounter = 'Private Bytes' THEN 'Prvt_Bytes' 
    WHEN mem.PerfCounter = 'Page Faults/sec' THEN 'Page_Faults_Sec' 
    WHEN mem.PerfCounter = 'Thread Count' THEN 'Threads' 
    WHEN mem.PerfCounter LIKE '%Handle%' THEN 'Handles' 
    END AS PerfCounter, 
    PerfInstance AS Application, 
    Value
FROM    dbo.AllPerf AS mem
And what I want is something like this:
--------------------------------------------------------------------------------------------
| mem.AlertTime       | Computer |Application| Vrt_Bytes| Prvt_Bytes| Handles| Page_Faults |
-------------------------------------------------------------------------------------------
| 2019-03-15 14:49:02 | WEB-04   | System    | 12440     | 24.13    |   13   |   0.14      |
| 2019-03-15 14:49:02 | WEB-04   | w3wp      | 7396      | 4.2309   |   13   |    0        |
| 2019-03-15 14:49:02 | WEB-05   | w3wp      | 1538      | 0.1368   |  1538  |    0        |
| 2019-03-15 14:49:02 | WEB-05   | System    | 6629      | 6500     |  1835  |    5        |
| 2019-03-15 14:49:02 | WEB-06   | System    | 2440      | 0.1368   |   13   |    0        |
--------------------------------------------------------------------------------------------
And If I had my pie-in-the-sky wish, I would covert the MBytes under Mem_Bytes to GB, but I couldn't successfully make CASE statements and include the math in the result
 
    
