MattSmithProg
Programmer
Hi,
I have a little problem trying to create a query so it returns in the manner I want.
I have some data that looks like this.
Type Due_Dt Fin_Dt Min_Sgn_Dt
MIN 22/12/2001 18/12/2001
MIN 18/01/2002 15/01/2002
MPC 25/03/2002 17/03/2002
MCO 18/02/2002 14/02/2002
What I know do to get the number of cases completed by the due date and the percentage of these cases is this.
SELECT
CASE WHEN Case_Type = 'MIN' THEN 'Ministerials'
WHEN Case_Type = 'MPC' THEN 'MP Corres'
WHEN Case_Type = 'MCO' THEN 'Misc Corres'
ELSE NULL END AS "Case Type",
("Within Ops"/NULLIFZERO( "Total Comp"
)*100 AS "% IN OPS",
COUNT(CASE WHEN Case_Type <> 'MIN' AND Due_Dt >= Fin_Dt THEN Case_Type
WHEN Case_Type = 'MIN' AND Due_Dt >= Min_Sgn_Dt THEN Case_Type END) AS "Within Ops",
COUNT(Case_Type) AS "Total Comp"
FROM PTAPP_YesMin_Main
WHERE Case_Type <> 'PH' AND (Fin_Dt BETWEEN '2001-07-01' AND '2002-06-30') OR (Min_Sgn_Dt BETWEEN '2001-07-01' AND '2002-06-30' AND Case_Type = 'MIN')
GROUP BY "Case Type"
Note: There is a difference between the Fin_Dt for Min and other Case Types.
What I know want is to have a breakup of months and achievement results. I would like the data to look like this.
Achievement Jul Aug Sep Oct ....
Ministerial % In Ops 25 50 75 30 ....
Ministerial Within Ops 12 16 3 3 ....
Ministerial Total Comp 4 8 4 10 ....
MP Corres % In Ops .....................
MP Corres Within Ops .....................
MP Corres Total Comp .....................
..
...
....
I hope this makes sense and someone can help me. I have an urgent deadline and need to get this done.
Matt Smith
No two nulls are the same
I have a little problem trying to create a query so it returns in the manner I want.
I have some data that looks like this.
Type Due_Dt Fin_Dt Min_Sgn_Dt
MIN 22/12/2001 18/12/2001
MIN 18/01/2002 15/01/2002
MPC 25/03/2002 17/03/2002
MCO 18/02/2002 14/02/2002
What I know do to get the number of cases completed by the due date and the percentage of these cases is this.
SELECT
CASE WHEN Case_Type = 'MIN' THEN 'Ministerials'
WHEN Case_Type = 'MPC' THEN 'MP Corres'
WHEN Case_Type = 'MCO' THEN 'Misc Corres'
ELSE NULL END AS "Case Type",
("Within Ops"/NULLIFZERO( "Total Comp"
COUNT(CASE WHEN Case_Type <> 'MIN' AND Due_Dt >= Fin_Dt THEN Case_Type
WHEN Case_Type = 'MIN' AND Due_Dt >= Min_Sgn_Dt THEN Case_Type END) AS "Within Ops",
COUNT(Case_Type) AS "Total Comp"
FROM PTAPP_YesMin_Main
WHERE Case_Type <> 'PH' AND (Fin_Dt BETWEEN '2001-07-01' AND '2002-06-30') OR (Min_Sgn_Dt BETWEEN '2001-07-01' AND '2002-06-30' AND Case_Type = 'MIN')
GROUP BY "Case Type"
Note: There is a difference between the Fin_Dt for Min and other Case Types.
What I know want is to have a breakup of months and achievement results. I would like the data to look like this.
Achievement Jul Aug Sep Oct ....
Ministerial % In Ops 25 50 75 30 ....
Ministerial Within Ops 12 16 3 3 ....
Ministerial Total Comp 4 8 4 10 ....
MP Corres % In Ops .....................
MP Corres Within Ops .....................
MP Corres Total Comp .....................
..
...
....
I hope this makes sense and someone can help me. I have an urgent deadline and need to get this done.
Matt Smith
No two nulls are the same