if suppose i am having an ACCOUNT table with 3 coloumns ACC.
NO,ACC. NAME,ACC. AMOUNT . If a unique index is also
defined on ACC.NO and ACC.NAME then write a query to
retrieve account holders records who have more than 1 ACC.

Answers were Sorted based on User's Feedback



if suppose i am having an ACCOUNT table with 3 coloumns ACC. NO,ACC. NAME,ACC. AMOUNT . If a uniqu..

Answer / ram prajapati

sir,
is it possible to have duplicate values for a uniquely
defined column.........or ... is it possible to define a
unique index on a column which is not having unique value?
plz help me out..

Is This Answer Correct ?    3 Yes 0 No

if suppose i am having an ACCOUNT table with 3 coloumns ACC. NO,ACC. NAME,ACC. AMOUNT . If a uniqu..

Answer / mallikarjun

select distinct ACC.NO,
ACC. NAME,
ACC. AMOUNT

from account
where acc.name in
( select distinct acc.name
from account
group by acc.name
where count(acc.no) > 1)

Is This Answer Correct ?    3 Yes 1 No

if suppose i am having an ACCOUNT table with 3 coloumns ACC. NO,ACC. NAME,ACC. AMOUNT . If a uniqu..

Answer / s

For this scenario duplicate records will not exist in the
table as the index has been defined on the 2 primary keys.

Hence the answer is we can't pull the account holders
having more than 1 account

Is This Answer Correct ?    1 Yes 0 No

if suppose i am having an ACCOUNT table with 3 coloumns ACC. NO,ACC. NAME,ACC. AMOUNT . If a uniqu..

Answer / suleman

Try this one


select ACC.NO,ACC.NAME
FROM ACCOUNT
group by ACC.NO
HAVING COUNT(*) > 1

Is This Answer Correct ?    1 Yes 1 No

if suppose i am having an ACCOUNT table with 3 coloumns ACC. NO,ACC. NAME,ACC. AMOUNT . If a uniqu..

Answer / lol

select ACC.NO||ACC.Name from ACCOUNT having count(acc.no||acc.name) >1

Is This Answer Correct ?    0 Yes 0 No

if suppose i am having an ACCOUNT table with 3 coloumns ACC. NO,ACC. NAME,ACC. AMOUNT . If a uniqu..

Answer / ratheesh nellikkal

Hi All,

Here u already have a unique index defined on ACC.NO and ACC.NAME feilds.
Unique index will not allow more than one value for this particular field (Correct me if I am wrong).
Then hw can we get more that one a/c no for a person in this scenario ?

So the answer will be, u can not store more than one a/c number for a person since u have a unique indexes on these table.

Regards,
Ratheesh Nellikal

Is This Answer Correct ?    1 Yes 2 No

if suppose i am having an ACCOUNT table with 3 coloumns ACC. NO,ACC. NAME,ACC. AMOUNT . If a uniqu..

Answer / rihaan

Thanks a lot Mr.Mallikarjun but the inner query u wrote
alone does the work.
kindly check it up

Is This Answer Correct ?    0 Yes 2 No

if suppose i am having an ACCOUNT table with 3 coloumns ACC. NO,ACC. NAME,ACC. AMOUNT . If a uniqu..

Answer / anandrao

please try this solution also

select count(*),ACC.NO
FROM ACCOUNT
group by ACC.NO
HAVING COUNT(*) > 1

Is This Answer Correct ?    0 Yes 2 No

Post New Answer

More DB2 Interview Questions

What is coalesce in db2?

0 Answers  


In SPUFI suppose you want to select maximum of 1000 rows, but the select returns only 200 rows. What are the 2 SQLCODEs that are returned?

1 Answers  


What do you need to do before you do EXPLAIN?

1 Answers  


What is a collection?

3 Answers  


How can we retrieve the total number of records in RPG & CLLE?

0 Answers  






what is different three logs in DB2?

1 Answers   Syntel,


What are column-name qualifiers used?

1 Answers  


How do you define a correlated name?

1 Answers  


What is the clustering index in the db2 database?

0 Answers  


have 3 tables table1, table2 and table3 which contains employee information. table1 is master table, table2 contains emp details like emp no and so on, table 3 contains emp salary. so if any emp leave company between 25th - 30th of every month it has to get updated in tables. but it is not getting updated. What is the reason.

0 Answers  


Is it Possible to read from PS file and write it to database by using dynamic sql(execute immediate)

2 Answers  


Can we use select * statement in cobol program without giving field names ???

3 Answers   Zensar,


Categories