Home » SQL & PL/SQL » SQL & PL/SQL » Req Help in pl/sql query
Req Help in pl/sql query [message #264302] Sun, 02 September 2007 23:52 Go to next message
kanis
Messages: 61
Registered: November 2006
Member
I have a table like as below

id Val
A1 M1
A1 M5
A1 M2
A2 M1
A2 M2
A3 M2
A3 M4
A4 M1
A4 M2
A5 M1
-- --
-- --
An Mn

Now i need to write a query in a procedure where
1. input will be the id (like A1,A2..)

Output should be the common value between input id.

For example if input is A1 and A2 then o/p should be only M1.
If i/p is A1,A2,A3 then o/p should be M2.
Input can be any number of id's.

Can any one help me??
My oracle version is
"Oracle9i Enterprise Edition Release 9.0.1.1.1"
Re: Req Help in pl/sql query [message #264307 is a reply to message #264302] Mon, 03 September 2007 00:05 Go to previous messageGo to next message
BlackSwan
Messages: 25050
Registered: January 2009
Location: SoCal
Senior Member
>Can any one help me??
Can you help yourself by reading & FOLLOWING the posting guidelines as stated in the STICKY posts at the top of this forum?
Re: Req Help in pl/sql query [message #264309 is a reply to message #264307] Mon, 03 September 2007 00:07 Go to previous messageGo to next message
pablolee
Messages: 2836
Registered: May 2007
Location: Scotland
Senior Member
anacedent wrote on Mon, 03 September 2007 06:05
>Can any one help me??
Can you help yourself by reading & FOLLOWING the posting guidelines as stated in the STICKY posts at the top of this forum?

Probably not Wink
Re: Req Help in pl/sql query [message #264312 is a reply to message #264302] Mon, 03 September 2007 00:14 Go to previous messageGo to next message
Arju
Messages: 1554
Registered: June 2007
Location: Dhaka,Bangladesh. Mobile:...
Senior Member

select val from id_val where id='A1'
intersect
select val from id_val where id='A2';


Implement it in a procedure.
Re: Req Help in pl/sql query [message #264321 is a reply to message #264312] Mon, 03 September 2007 00:41 Go to previous messageGo to next message
Michel Cadot
Messages: 64153
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Unexpected and good solution! (generally speaking nothing personal)
Thinking set is now rare when most people think procedure.

Thanks
Michel
Re: Req Help in pl/sql query [message #264359 is a reply to message #264302] Mon, 03 September 2007 02:06 Go to previous messageGo to next message
Arju
Messages: 1554
Registered: June 2007
Location: Dhaka,Bangladesh. Mobile:...
Senior Member

Michel, I am almost new in SQL/PL,SQL.

I could not understand the meaning of it,
Quote:
Thinking set is now rare when most people think procedure.


Do you want to mean it is always likely to use procedure instead of
just writing SQL.
Re: Req Help in pl/sql query [message #264375 is a reply to message #264359] Mon, 03 September 2007 02:33 Go to previous messageGo to next message
Michel Cadot
Messages: 64153
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Quote:
Do you want to mean it is always likely to use procedure instead of just writing SQL.

No, this is the opposite.
SQL is a set language but most people think procedural (how many questions there are asking PL/SQL when SQL is what must be used).
I'm impressed when someone post a solution using set operation. This approach now goes against the general way of thinking.

Regards
Michel

Re: Req Help in pl/sql query [message #264376 is a reply to message #264302] Mon, 03 September 2007 02:36 Go to previous message
Arju
Messages: 1554
Registered: June 2007
Location: Dhaka,Bangladesh. Mobile:...
Senior Member

So , I am in a right way as a newbie! Cool
Previous Topic: Please help on this query
Next Topic: %age use using COUNT()
Goto Forum:
  


Current Time: Sun Dec 11 02:39:07 CST 2016

Total time taken to generate the page: 0.04019 seconds