Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Show a zero value if no value is found

Status
Not open for further replies.

ttiiffffnnhh22000022

Technical User
Mar 30, 2017
1
US
I am trying to display all JPNUMS and it's count of labor and tasks. They query below is only showing JPNUMS where there is labor and tasks however I want to show the JPNUMS where labor and/or tasks are also zero.

SELECT JP.JPNUM, JP.STATUS,
JPT.TASKCOUNT,
JPL.CRAFTCOUNT
FROM
(SELECT JPNUM, STATUS, COUNT(*) JPCOUNT
FROM MISSO.JOBPLAN JP
WHERE PLUSCREVNUM = (SELECT MAX(PLUSCREVNUM) FROM MISSO.JOBPLAN WHERE JPNUM = JP.JPNUM)
AND STATUS IN ('DRAFT','ACTIVE','PNDREV') and ORGID='GOM'
GROUP BY JPNUM, STATUS
) JP,
(SELECT JPNUM,COUNT(*) TASKCOUNT
FROM MISSO.JOBTASK JT
WHERE PLUSCJPREVNUM =(SELECT MAX(PLUSCJPREVNUM) FROM MISSO.JOBTASK WHERE JPNUM = JT.JPNUM)
GROUP BY JPNUM
) JPT,
(SELECT JPNUM,COUNT(*) CRAFTCOUNT
FROM MISSO.JOBLABOR JL
WHERE PLUSCJPREVNUM =(SELECT MAX(PLUSCJPREVNUM) FROM MISSO.JOBTASK WHERE JPNUM = JL.JPNUM)
GROUP BY JPNUM
) JPL
where JP.JPNUM = JPL.JPNUM
AND JPL.JPNUM = JPT.JPNUM
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top