Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1089317
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T23:12:12+00:00 2026-05-16T23:12:12+00:00

Can any one please help with select script? desired outcome TABLENAME, ATTRIBUTE, NULLABLE, DATATYPE,

  • 0

Can any one please help with select script?

desired outcome

 TABLENAME, ATTRIBUTE, NULLABLE, DATATYPE, LENGTH, DESC, HELP_TEXT having count(datadic.ATTRIBUTE)>1  (because these can only be unique) 

and is not unique to any other attribute (not include DDKEY and SerNo) with the same value.

i.e

 TABLE2 ADDR4 NULL VARCHAR2 15 Unit Address Line 4 Unit address line 4 
 TABLE1 ADDR4 NULL VARCHAR2 30 Unit Address Line 4 Unit address line 4 

I am trying to get my head around nested queries

Real life senerio I want to see if my database has any attributes with different values in different tables a sort of house keeping exercise.

I have 154 table 700 attributes

so far

 select attribute,count(DATADIC.ATTRIBUTE) as "ATTRIBUTE" 
 from "DATADIC" "DATADIC"
 group by DATADIC.ATTRIBUTE 
 having count(datadic.ATTRIBUTE)>1)
 order by count(DATADIC.ATTRIBUTE)

then

 select TABLENAME,ATTRIBUTE,NULLABLE, DATATYPE, LENGTH, DESC, HELP_TEXT 
 from datadic 
 where      
 attribute in
 (select attribute,count(DATADIC.ATTRIBUTE) as "ATTRIBUTE" 
   from "DATADIC" "DATADIC"
   group by DATADIC.ATTRIBUTE
   having count(datadic.ATTRIBUTE)>1)
   order by count(DATADIC.ATTRIBUTE)

has too many values

 desc
 DATADIC.
  DDKEY Number 
  SER Number 
  TABLENAME Varchar2 15 
  ATTRIBUTE Varchar2 25
  NULLABLE Varchar2 10 
  DATATYPE Varchar2 15  
  LENGTH number(7,3) 
  DESCRIPTION Varchar2 30
  HELP_TEXT Varchar2 1000

sample data

556 5 TABLE2 ADDR1 NULL VARCHAR2 30 Unit Address Line 1 Unit address line 1 
545 5 TABLE1 ADDR1 NULL VARCHAR2 30 Unit Address Line 1 Unit address line 1 
546 6 TABLE1 ADDR2 NULL VARCHAR2 30 Unit Address Line 2 Unit address line 2 
557 6 TABLE2 ADDR2 NULL VARCHAR2 30 Unit Address Line 2 Unit address line 2 
547 7 TABLE1 ADDR3 NULL VARCHAR2 30 Unit Address Line 3 Unit address line 3 
558 7 TABLE2 ADDR3 NULL VARCHAR2 30 Unit Address Line 3 Unit address line 3 
559 8 TABLE2 ADDR4 NULL VARCHAR2 15 Unit Address Line 4 Unit address line 4 
548 8 TABLE1 ADDR4 NULL VARCHAR2 30 Unit Address Line 4 Unit address line 4 

useful script

CREATE TABLE  "DATADIC" 
(   "DDKEY" NUMBER, 
"SER" NUMBER, 
"TABLENAME" VARCHAR2(15), 
"ATTRIBUTE" VARCHAR2(25), 
"NULLABLE" VARCHAR2(10), 
"DATATYPE" VARCHAR2(15), 
"LENGTH" NUMBER(7,3), 
"DESCRIPTION" VARCHAR2(30), 
"HELP_TEXT" VARCHAR2(1000), 
 CONSTRAINT "DATADIC_PK" PRIMARY KEY ("DDKEY") ENABLE
)

/

CREATE OR REPLACE TRIGGER  "bi_DATADIC" 
before insert on "DATADIC"              
for each row 
begin  
  for c1 in ( 
   select "DATADIC_SEQ".nextval next_val 
    from dual 
  ) loop 
  :new."DDKEY" :=  c1.next_val; 
 end loop; 
end;

/
ALTER TRIGGER  "bi_DATADIC" ENABLE
/

data csv

 556,5,TABLE2,ADDR1,NULL,VARCHAR2,30,Unit Address Line 1,Unit address line 1
 557,6,TABLE2,ADDR2,NULL,VARCHAR2,30,Unit Address Line 2,Unit address line 2
 558,7,TABLE2,ADDR3,NULL,VARCHAR2,30,Unit Address Line 3,Unit address line 3
 559,8,TABLE2,ADDR4,NULL,VARCHAR2,15,Unit Address Line 4,Unit address line 4
 545,5,TABLE1,ADDR1,NULL,VARCHAR2,30,Unit Address Line 1,Unit address line 1
 546,6,TABLE1,ADDR2,NULL,VARCHAR2,30,Unit Address Line 2,Unit address line 2
 547,7,TABLE1,ADDR3,NULL,VARCHAR2,30,Unit Address Line 3,Unit address line 3
 548,8,TABLE1,ADDR4,NULL,VARCHAR2,30,Unit Address Line 4,Unit address line 4

updated data is now using this query but I need not make the not unique

select * from (
select TABLENAME,
ATTRIBUTE,
NULLABLE,
DATATYPE,
LENGTH,
DESCRIPTION,
HELP_TEXT,
count(*) over (partition by attribute) attr_count
from datadic
) where attr_count > 1

TABLENAME ATTRIBUTE NULLABLE DATATYPE LENGTH DESCRIPTION HELP_TEXT ATTR_COUNT
TABLE2 ADDR1 NULL VARCHAR2 30 Unit Address Line 1 Unit address line 1 2
TABLE1 ADDR1 NULL VARCHAR2 30 Unit Address Line 1 Unit address line 1 2
TABLE1 ADDR2 NULL VARCHAR2 30 Unit Address Line 2 Unit address line 2 2
TABLE2 ADDR2 NULL VARCHAR2 30 Unit Address Line 2 Unit address line 2 2
TABLE1 ADDR3 NULL VARCHAR2 30 Unit Address Line 3 Unit address line 3 2
TABLE2 ADDR3 NULL VARCHAR2 30 Unit Address Line 3 Unit address line 3 2
TABLE2 ADDR4 NULL VARCHAR2 30 Unit Address Line 4 Unit address line 4 2
TABLE1 ADDR4 NULL VARCHAR2 30 Unit Address Line 4 Unit address line 4 2

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T23:12:12+00:00Added an answer on May 16, 2026 at 11:12 pm

    select TABLENAME,ATTRIBUTE,NULLABLE,
    DATATYPE, LENGTH, DESC, HELP_TEXT from
    datadic where attribute in (select
    attribute,count(DATADIC.ATTRIBUTE) as
    “ATTRIBUTE” from “DATADIC” “DATADIC”
    group by DATADIC.ATTRIBUTE having
    count(datadic.ATTRIBUTE)>1) order by
    count(DATADIC.ATTRIBUTE)

    You are getting a too many values because the query is expecting one column after the “IN” Clause. Try the following query to get all the rows in the table with an attribute that has occurred more than once.

    select TABLENAME,
           ATTRIBUTE,
           NULLABLE, 
           DATATYPE, 
           LENGTH, 
           DESC, 
           HELP_TEXT 
      from datadic 
      where attribute in 
      (
      select attribute from (
      select attribute,
             count(DATADIC.ATTRIBUTE) as "ATTRIBUTE" 
       from "DATADIC" "DATADIC" 
       group by DATADIC.ATTRIBUTE 
       having count(datadic.ATTRIBUTE)>1) 
       order by count(DATADIC.ATTRIBUTE)
       )
      )
    

    You can make good use of Analytic functions to answer this query in a simpler way.

    select * from (
    select TABLENAME,
           ATTRIBUTE,
           NULLABLE, 
           DATATYPE, 
           LENGTH, 
           DESC, 
           HELP_TEXT,
           count(*) over (partition by attribute) attr_count 
      from datadic
    ) where attr_count > 1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can any one please help me, how to assign result of select query to
Can any one please help me how to go to another activity in android
Can any one please help me solve this. I am resizing some flash object/embed
Can any one please help me how to convert date(02/07/2012) to Tuesday, Febraury 7,
Can any one Help me Please I want to Calculate 2 or more row
Can any one please help me? I am new to php, currently I am
Can some one please help explain why when I block and continue observer's onNext
Please any one help me to show and hide the text box appropriately. Response:
can any one help me on how can I create a query output using
Can anyone please help me to know how to open an excel sheet in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.