Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8184953
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T01:40:44+00:00 2026-06-07T01:40:44+00:00

Afternoon good people of Stack Overflow. I am trying to do something that I

  • 0

Afternoon good people of Stack Overflow.

I am trying to do something that I am not certain how to achieve with my SQL knowledge, but I have a clear idea what it is I want out of this so hopefully this will make sense to people.

I have some perfmon disk results that look like this:

DatabaseName    ObjectName      CounterName         InstanceName                Server      Average
DAG1DB01        logicaldisk     avg. disk sec/read  d:\mountpoints\DAG1DB01     Server1     13.616
DAG1DB01        logicaldisk     avg. disk sec/read  d:\mountpoints\DAG1DB01     Server2     17.508
DAG1DB01        logicaldisk     avg. disk sec/read  d:\mountpoints\DAG1DB01     Server3     12.775
DAG1DB01        logicaldisk     avg. disk sec/read  d:\mountpoints\DAG1DB01     Server4     13.148
DAG1DB01        logicaldisk     avg. disk sec/read  d:\mountpoints\DAG1DB01     Server5     10.091

These are example rows based on this query:

SELECT
e14_db.DatabaseName AS [DatabaseName],
d.ObjectName,
d.CounterName,
d.InstanceName,
d.Server,
AVG(Value) * 1000 AS [Average]
FROM E14_Perfmon_MBX AS d
INNER JOIN E14_Databases AS e14_db
ON e14_db.LogFolderPath = d.InstanceName
WHERE d.ObjectName = 'logicaldisk'
AND d.CounterName = 'avg. disk sec/read'
AND d.DateTime > (DATEADD(hh, -4, GETDATE()))
AND d.Value < 1
GROUP BY d.ObjectName, d.CounterName, d.InstanceName, d.Server, e14_db.DatabaseName
ORDER BY e14_db.DatabaseName, d.Server

What I want is this:

DatabaseName    ObjectName      CounterName         InstanceName                Server1     Server2     Server3     Server4     Server5
DAG1DB01        logicaldisk     avg. disk sec/read  d:\mountpoints\DAG1DB01     13.616      17.508      12.775      13.148      10.091

Does anyone know how I can achieve this? basically applying the rows onto themselves?

If any clarification is needed please feel free to ask.

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T01:40:45+00:00Added an answer on June 7, 2026 at 1:40 am

    The following statement calculates separate averages for each server in a fixed number of columns (from 1 to 5):

    SELECT e14_db.DatabaseName AS [DatabaseName]
    , d.ObjectName, d.CounterName, d.InstanceName
    , AVG(CASE WHEN d.Server = 'Server1' THEN Value ELSE NULL END) *1000 AS [Server1]
    , AVG(CASE WHEN d.Server = 'Server2' THEN Value ELSE NULL END) *1000 AS [Server2]
    , AVG(CASE WHEN d.Server = 'Server3' THEN Value ELSE NULL END) *1000 AS [Server3]
    , AVG(CASE WHEN d.Server = 'Server4' THEN Value ELSE NULL END) *1000 AS [Server4]
    , AVG(CASE WHEN d.Server = 'Server5' THEN Value ELSE NULL END) *1000 AS [Server5]
    FROM E14_Perfmon_MBX AS d
    INNER JOIN E14_Databases AS e14_db
    ON e14_db.LogFolderPath = d.InstanceName
    WHERE d.ObjectName = 'logicaldisk'
    AND d.CounterName = 'avg. disk sec/read'
    AND d.DateTime > (DATEADD(hh, -4, GETDATE()))
    AND d.Value < 1
    GROUP BY d.ObjectName, d.CounterName, d.InstanceName, e14_db.DatabaseName
    ORDER BY e14_db.DatabaseName
    

    You can use PIVOT as well, but this syntax is supported by a broader range of SQL flavors.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Good afternoon people's I have built a jquery plugin that I use on my
Good Afternoon, I have a html aspx page that has many many div elements.
Good Afternoon All, I have written an SSIS 2005 package that contains a conditional
Good Afternoon, I'm currently trying to build something incredibly simple inside of the Google
Good afternoon, I have three entities (that concern this question) Company (ID, etc..) CompanyAddress
Good afternoon everybody! I have this threaded SerialPort wrapper that reads in a line
Good Afternoon, I am trying to use the composite filter but in vain. While
Very good afternoon to all, The problem I have now is that I can
Good afternoon. I have been making a small openGL based app for android that
Good afternoon, I wish to have a script that will look for all files

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.