I am using SQL Server 2000 and I have a table that contains a column of job_name and cpu_time. Every time a job completes the job_name and cpu_time used is interted to the table. I have been asked to find the cpu_time of the 75th percentile for each job_name. There are over 50,000 rows with about 200 unique job_names
I have used the following code to get the result I need, but I have to recode the job_name every time I want look at a different job_name.
SQL Code
--------
Is there a way to repeat this code for each distinct job_name in table job_hist_tbl?
The job_hist_tbl contains:
job_name cpu_time
-------- --------
ARRPMT 6
ARRPMT 8
ARRPMT 10
ARRPMT 12
GLRACWLD 1
GLRACWLD 2
GLRACWLD 4
GLRACWLD 9
GLRINQAC 3
GLRINQAC 5
GLRINQAC 7
GLRINQAC 11
The results I expect to get are:
job_name cpu_time
-------- --------
ARRPMT 10
GLRACWLD 4
GLRINQAC 7
I have used the following code to get the result I need, but I have to recode the job_name every time I want look at a different job_name.
SQL Code
--------
Code:
select top 1 b.job_name, b.cpu_time
from (
select top 75 percent *
from job_hist_tbl
where name = 'ARRPMT'
order by cpu_time ASC
)b
order by b.cpu_time DESC
Is there a way to repeat this code for each distinct job_name in table job_hist_tbl?
The job_hist_tbl contains:
job_name cpu_time
-------- --------
ARRPMT 6
ARRPMT 8
ARRPMT 10
ARRPMT 12
GLRACWLD 1
GLRACWLD 2
GLRACWLD 4
GLRACWLD 9
GLRINQAC 3
GLRINQAC 5
GLRINQAC 7
GLRINQAC 11
The results I expect to get are:
job_name cpu_time
-------- --------
ARRPMT 10
GLRACWLD 4
GLRINQAC 7