I have a table that contains address information for everyone in the system. It has numerous fields, though I've only included a few in the create table query below for the sake of brevity. The PIDM uniquely identifies each record as belonging to a particular person in the database. A person can have multiple addresses in the table, though we normally do not allow them to have more than one active address of a particular ATYP_CODE. Again, I am doing this here for the sake of brevity. What I need to do is pull all the records for each PIDM, but only where there are >= 6 records per PIDM. The user doesn't care if the data are pivoted (I can do that part if needed). Pulling the actual data isn't the issue. I just need a little help figuring out how to get only the records of PIDMs with six or more records in the table. So, from the example data below, the records for PIDM 12345 and 34567 are the ones that should be in the output, but the ones from PIDM 23456 should not.
DROP TABLE SPRADDR;
CREATE TABLE SPRADDR
(PIDM NUMBER(8),
ATYP_CODE VARCHAR2(2 CHAR),
STREETLINE1 VARCHAR2(60 CHAR),
CITY VARCHAR2(60 CHAR),
STATE VARCHAR2(2 CHAR),
ZIP VARCHAR2(10));
INSERT INTO SPRADDR VALUES (12345,'PR','1 MAIN','CANFIELD','OH','44406');
INSERT INTO SPRADDR VALUES (12345,'MA','1 MAIN','CANFIELD','OH','44406');
INSERT INTO SPRADDR VALUES (12345,'BU','1 MAIN','CANFIELD','OH','44406');
INSERT INTO SPRADDR VALUES (12345,'PR','2 MAIN','CANFIELD','OH','44406');
INSERT INTO SPRADDR VALUES (12345,'MA','3 MAIN','CANFIELD','OH','44406');
INSERT INTO SPRADDR VALUES (12345,'PR','4 MAIN','CANFIELD','OH','44406');
INSERT INTO SPRADDR VALUES (23456,'PR','1 MAIN','KENT','OH','44240');
INSERT INTO SPRADDR VALUES (23456,'MA','1 MAIN','KENT','OH','44240');
INSERT INTO SPRADDR VALUES (23456,'BU','1 MAIN','KENT','OH','44240');
INSERT INTO SPRADDR VALUES (34567,'PR','1 MAIN','CANFIELD','OH','44406');
INSERT INTO SPRADDR VALUES (34567,'MA','1 MAIN','CANFIELD','OH','44406');
INSERT INTO SPRADDR VALUES (34567,'BU','1 MAIN','CANFIELD','OH','44406');
INSERT INTO SPRADDR VALUES (34567,'PR','2 MAIN','CANFIELD','OH','44406');
INSERT INTO SPRADDR VALUES (34567,'MA','3 MAIN','CANFIELD','OH','44406');
INSERT INTO SPRADDR VALUES (34567,'PR','4 MAIN','CANFIELD','OH','44406');
INSERT INTO SPRADDR VALUES (34567,'PR','6 MAIN','CANFIELD','OH','44406');
COMMIT;
I'd greatly appreciate any help you might be able to provide. I'm sure this is easy, but what I've done so far has not worked and I'm not including the code I tried because it's totally cockeyed and not working at all.
Thanks,
Michelle Craig
Data Coordinator
Admissions Operations and Transfer Systems
Kent State University