Advertisement
bytecoded

Top Queries

Mar 9th, 2019
362
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 0.62 KB | None | 0 0
  1. SELECT
  2.     sql_texts.[HashSQL]             AS "SQL",
  3.     top_queries.[Total CPU Used]    AS "CPU",
  4.     top_queries.[Execution Count]   AS "Execution Count"
  5.  
  6. FROM
  7.     (
  8.         SELECT
  9.             [HashSQLMD5]            AS "HashSQLMD5",
  10.             SUM([Total CPU Used])   AS "Total CPU Used",
  11.             SUM([Execution Count])  AS "Execution Count"
  12.  
  13.         FROM #top_queries_04
  14.  
  15.         GROUP BY [HashSQLMD5]
  16.     ) top_queries
  17.  
  18.     INNER JOIN (SELECT DISTINCT [HashSQL], [HashSQLMD5] FROM #top_queries_04) sql_texts
  19.     ON sql_texts.[HashSQLMD5] = top_queries.HashSQLMD5
  20.  
  21. ORDER BY top_queries.[Total CPU Used] DESC
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement