Oracle... yuck. OK, I'll do my best.
Let's simplify this 8 table join as best we can...
1) You're not retrieving any data from ValidWork, ValidSub, or
ValidProcess, nor are you using them in any intermediate join steps. Let's
remove them from the FROM and WHERE clauses.
2) It appears that the "truth" table here is FolderProcessAttempt. I'll
assume that "attemptBy" is the person's name (not the best design pattern,
but that's a different topic of discussion). Let's try a LEFT OUTER JOIN to
that table, so that you'll see all the FolderGroupDesc values, whether or
not they have corresponding rows in FolderProcessAttempt. We have to move
the date comparison from the WHERE clause here too, otherwise we'll
eliminate the null-supplying rows (making the left outer join useless)
3) You had a number of WHERE clause conditions duplicated. That's not a
problem for the Oracle parser, it just muddies the SQL a lot.
SELECT
validfoldergroup.foldergroupdesc,
FolderProcessAttempt.attemptby,
to_char(FolderProcessAttempt.attemptdate,'DD-MON-YYYY')
FROM
Folder, ValidFolder, ValidFolderGroup, FolderProcess
LEFT OUTER JOIN FolderProcessAttempt
ON FolderProcess.ProcessRSN = FolderProcessAttempt.ProcessRSN
and FolderProcessAttempt.attemptdate
between :Date1MMDDYY AND :Date2MMDDYY
WHERE
ValidFolder.FolderType = Folder.FolderType and
ValidFolderGroup.FolderGroupCode = ValidFolder.FolderGroupCode and
Folder.FolderRSN = FolderProcess.FolderRSN and
ValidProcess.ProcessCode = FolderProcess.ProcessCode and
folder.foldertype in
('AV','BD','TX','CV','DI','LO','TO','TP','TW') and
FolderProcess.processcode in ('9020', '9030','9140') ;
Start with that, and see if it doesn't get you closer. We'll tackle the
other approach if this doesn't work.
--
Paul Horan[Sybase]
paulhoran.pbdjmagazine.com
Post by unknownhello
thank you soooooo much for your quick response. I kind of
understand what you are suggesting but I think I have a
problem with one of my columns because its a date.
I pasted the original script I was working from in
infomaker. I just don't think I can sum my attempt date. I
was doing that in infomaker. Let me know what you think.
Thanks!
Select
validfoldergroup.foldergroupdesc,
FolderProcessAttempt.attemptby,
to_char(FolderProcessAttempt.attemptdate,'DD-MON-YYYY')
from
folder, FolderProcessAttempt, FolderProcess, ValidFolder,
ValidFolderGroup, ValidProcess, ValidSub, ValidWork
where
ValidFolder.FolderType = Folder.FolderType
and ValidFolderGroup.FolderGroupCode =
ValidFolder.FolderGroupCode
and ValidWork.WorkCode = Folder.WorkCode
and ValidSub.SubCode = Folder.SubCode
and Folder.FolderRSN = FolderProcess.FolderRSN
and ValidProcess.ProcessCode = FolderProcess.ProcessCode
and ValidFolderGroup.FolderGroupCode =
ValidFolder.FolderGroupCode and ValidFolder.FolderType =
Folder.FolderType and Folder.FolderRSN =
FolderProcess.FolderRSN and FolderProcess.ProcessRSN =
FolderProcessAttempt.ProcessRSN
and FolderProcessAttempt.attemptdate between :Date1MMDDYY
AND :Date2MMDDYY
and folder.foldertype in
('AV','BD','TX','CV','DI','LO','TO','TP','TW')
and FolderProcess.processcode in ('9020', '9030','9140')