Topic: Oracle Certified Professional Exams (OCP & OCA) >> Need a answer for a Query....
|
Disclaimer: The purpose of all dbapool forums including OCP and Other Oracle Certification forums is to help each other with specific issues but not to share dump and copyrighted exam content, materials or intellectual property.
You may review the entire Oracle Certification Program Candidate Agreement online Here.
|
|
|
|
| Title: Need a answer for a Query.... |
| priya |
Posted: Apr 17, 2007 02:10:43 AM |
Total Post: 39
Joined: Apr, 2007
|
TABLE 1 -
CUSTOMER ID ACCNT NUMBER
1 A1
1 B1
1 c1
2 A2
3 A3
3 B3
4 C1
TABLE 2-
ACCNT NUMBER BANK NAME
A1 HSBC
B1 ICICI
C1 HSBC
A2 HSBC
A3 HSBC
B3 ICICI
C1 HSBC
What is the query to print the customer IDs who have accounts in ALL the banks
(IN THIS INSTANCE THE QUERY SHOULD RETURN 1 AND 3)
|
|
|
gps |
| Posted: Apr 17, 2007 07:45:49 AM | |
|
Total Post: 38
Joined: May, 2006
|
Try this query ...
select customer_id
from (select customer_id,bank_name from table1 a, table2 b
where a.account_no=b.account_no
group by customer_id,bank_name)
group by customer_id having count(*)=
(select count(distinct bank_name) from table2)
Gurwinder
|
|
|
|
|
priya |
| Posted: Apr 17, 2007 07:56:27 AM | |
|
Total Post: 39
Joined: Apr, 2007
|
hi,
thanks verymuch..
got it.
priya
|
|
|
|
|
| Time Zone: EDT |
Send this thread to your friend |
|
|
|
|
Forum Rules & Description
Who Can Read The Forum? Any registered user or guest
Who Can Post New Topics? Any registered user
Who Can Post Replies? Any registered user
|
| |
Get FREE Magazines
|
Top 10 Forum User
|
| Murtuja Khokhar | 814 |
| Mohammed Taj | 694 |
| Jayanta Sur | 479 |
| Vigyan Kaushik | 386 |
| positive fanatic | 361 |
| Gitesh Trivedi | 322 |
| Gopu Gopi | 239 |
| neeraj sharma | 228 |
| Ramesh Jois | 226 |
| snehalatha p | 169 |
|
|