Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Query that will pull only fields that have data

906512Aug 9 2012 — edited Aug 9 2012
In the database we use for transfer articulation, there are numerous tables delivered with the product. The institution decided not to use certain fields, and all instances of those fields have no data. In other words, there might be a field in the table called INSTCD, but no records in the table have ever inserted any data into that particular field. In the table there are thousands of records, and we don't necessarily know which of the fields have never been used (no list has been retained and no one who initially was involved in the decisions is available to ask), as there are multiple fields in each table. How can I write a query that pulls only the fields in the table that contain data. In the example below, the SHRTRIT table contains a field called ACTIVITY_DATE, but there is no data in any record in that particular field, so I don't want it to show up on the output. In this particular case, I KNOW not to pull this field in a SELECT, but in a case where there might be 130,000 records and I DON'T know if a field has records in it, how could I do that?

Please advise if the question I'm asking doesn't make sense and I'll attempt to word it better.

Thanks,
Michelle Craig
Kent State University
create table SHRTRIT
(
SBGI_CODE	VARCHAR2(6)	NOT NULL,
SBGI_DESC	VARCHAR2(10),
ACTIVITY_DATE	VARCHAR2(10)
)
/
INSERT INTO SHRTRIT
(SBGI_CODE,SBGI_DESC,ACTIVITY_DATE)
VALUES
(I08883,MING-CHUAN COLL,)
/
INSERT INTO SHRTRIT
(SBGI_CODE,SBGI_DESC,ACTIVITY_DATE)
VALUES
(I08883,MING-CHUAN COLL,)
/
INSERT INTO SHRTRIT
(SBGI_CODE,SBGI_DESC,ACTIVITY_DATE)
VALUES
(I08883,MING-CHUAN COLL,)
/
INSERT INTO SHRTRIT
(SBGI_CODE,SBGI_DESC,ACTIVITY_DATE)
VALUES
(I08883,MING-CHUAN COLL,)
/
INSERT INTO SHRTRIT
(SBGI_CODE,SBGI_DESC,ACTIVITY_DATE)
VALUES
(I07979,RIYADH TECHNICAL COLLEGE,)
/
INSERT INTO SHRTRIT
(SBGI_CODE,SBGI_DESC,ACTIVITY_DATE)
VALUES
(I07979,RIYADH TECHNICAL COLLEGE,)
/
{CODE}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 6 2012
Added on Aug 9 2012
9 comments
532 views