sagaya deni

Greenhorn
+ Follow
since Jan 05, 2007
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by sagaya deni

Three different queries have been written to get the count of same columns based on different conditions.But this results in hitting the database very often and thus performance comes down.So we want to write a query which combines all the three queries into a single one.We use three different methods to invoke these queries individually.This should be avoided and made into a single call and thereby hit the database only once.Here follows,the different queries........

Query1:
SELECT COUNT(JOB_ID) JOBID
FROM EOMS_JOB_QUEUE_V
WHERE JOB_STATUS_ID != 12
AND JOB_TYPE = 18
AND AGENT_ID =4

Query2:
SELECT COUNT(JOB_ID ) JOBID FROM
EOMS_JOB WHERE JOB_STATUS_ID != 12 AND JOB_TYPE = 20 AND AGENT_ID = 4

Query3:
SELECT COUNT(JOB_ID ) JOBID FROM "+
EOMS_JOB WHERE JOB_STATUS_ID != 12 AND JOB_TYPE = 19 AND AGENT_ID = 4

Note:In the above queries the job_type alone changes and the other conditions remains the same.
Three different queries have been written to get the count of same columns based on different conditions.But this results in hitting the database very often and thus performance comes down.So we want to write a query which combines all the three queries into a single one.We use three different methods to invoke these queries individually.This should be avoided and made into a single call and thereby hit the database only once.Here follows,the different queries........

Query1:
SELECT COUNT(JOB_ID) JOBID
FROM EOMS_JOB_QUEUE_V
WHERE JOB_STATUS_ID != 12
AND JOB_TYPE = 18
AND AGENT_ID =4

Query2:
SELECT COUNT(JOB_ID ) JOBID FROM
EOMS_JOB WHERE JOB_STATUS_ID != 12 AND JOB_TYPE = 20 AND AGENT_ID = 4

Query3:
SELECT COUNT(JOB_ID ) JOBID FROM "+
EOMS_JOB WHERE JOB_STATUS_ID != 12 AND JOB_TYPE = 19 AND AGENT_ID = 4

Note:In the above queries the job_type alone changes and the other conditions remains the same.