Unix Technical Forum

Re: newbie: select statement question

This is a discussion on Re: newbie: select statement question within the Oracle Miscellaneous forums, part of the Oracle Database category; --> "P. Griffioen" wrote: > Hello, > > I am having troubles figuring out how to get the following result ...


Go Back   Unix Technical Forum > Database Server Software > Oracle Database > Oracle Miscellaneous

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-07-2008, 08:53 AM
Daniel Morgan
 
Posts: n/a
Default Re: newbie: select statement question

"P. Griffioen" wrote:

> Hello,
>
> I am having troubles figuring out how to get the following result with a sql
> statement:
>
> suppose I have two columns (A and B), populated with the following data :
>
> A B
> 1 1
> 1 2
> 1 3
> 1 4
> 2 1
> 2 2
> 2 3
> 3 1
> 3 2
> 3 3
>
> Now, I want to get a selection of A and B where the value of B is in all
> selections of A(1,2,3,4).
>
> In the example above I want a return of all records -except- of the
> combination 1,4 (because 4 is only present in A(1) and not in the other
> values of A).
>
> I have tried some subselects and a joining of the same table; but i don't
> think that is the right approach.
>
> Thank you in advance for any hints.
>
> best regards,
> Peter


SELECT ...
FROM ...
WHERE ...
AND ...
AND ...
AND ...

Provided you can hard-code 1 through 4. If the number is dynamic and there are
considerations about missing numbers so that you can't just use BETWEEN ... you
are writing a PL/SQL procedure.
--
Daniel Morgan
http://www.outreach.washington.edu/e...ad/oad_crs.asp
damorgan@x.washington.edu
(replace 'x' with a 'u' to reply)


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 05:50 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com