Question : SELECT CRITERIA WITH GROUP BY PROBLEM

The user will need to list names of candidates with a particular last name, or those applying for a particular title.
I have 2 tables - candidate and roster history detail (rhd).   A candidate may or may not be in rhd, or may have
applied for multiple titles and have multiple records in rhd.  I want all names from the Candidate table, no matter
their status in rhd.

The criteria passed to this will either be by name ( or title, or both.  

I am trying to pass values to the WHERE clause to narrow the results, but don't want these columns included in the
GROUP BY clause.  I have a mental block about how to approach this - I keep hitting this problem over and over.
Any clarification would be appreciated!

I am now getting these results:

97201      000-00-0000      BOB      A      BERG      INSTRUCTOR
41433      000-00-0000      CHERYL      B      BERG      
200476      000-00-0000      DAVID            BERG      RECREATION AIDE
160441      000-00-0000      ELLA            BERG      CLERK TYPIST
160441      000-00-0000      ELLA            BERG      SCHOOL MONITOR
160441      000-00-0000      ELLA            BERG      SCHOOL TEACHER AIDE

I want:

97201      000-00-0000      BOB      A      BERG      
41433      000-00-0000      CHERYL      B      BERG      
200476      000-00-0000      DAVID            BERG      
160441      000-00-0000      ELLA            BERG      
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
SELECT
ca.Cand_id,
substr(SSnum,1,3) || '-' ||
substr(SSnum,4,2) || '-' ||
substr(SSNum,6,4) AS SSnum,
FName,
MI,
LName, rhd.title
FROM CANDIDATE ca,roster_history_detail rhd
where ca.cand_id = rhd.cand_id(+)
and lname like 'BERG%'
GROUP BY CA.CAND_ID,CA.SSNUM, CA.FNAME, CA.MI, CA.LNAME, rhd.title
ORDER BY CA.LNAME, CA.FNAME, CA.MI;
Open in New Window Select All

Answer : SELECT CRITERIA WITH GROUP BY PROBLEM

I believe I've answered the question, including sample code (23396946), and an alternative (23509016 + 23509030)
Random Solutions  
 
programming4us programming4us