-
sql query help...
I have a table structure
MemberDetails
----------------
MembershipDetailsID PK
MembershipID FK
Benefits Varchar
A MembershipID can contain many benefits which can be added.
At the time of retrieval i want a query to fetch all the benefits for this MembershipID in a single record.
i.e in normal suitations my query to fetch benefits is as following...
[B]select Benefits from MemberDetails where MembershipID=10;[/B] here i will get mutiple records.
what i want is a single record with Benefits values as comma seperated.
can you help me regarding this sub-query? is this posibble?is this question against the normalisation rules?
-
Re: sql query help...
hi
give your table with data and one sample req. o/p
-
Re: sql query help...
Hi Suresh,
Let me first understand your question...
If the Benefits columns has multiple records like below,
BENEFITS
----------------
LOW
MEDIUM
HIGH
It has to to displayed as LOW, MEDIUM, HIGH. Am i right?
If this is your requirement, this can be definitely achieved using a procedure where the column value is fetched using a cursor & concatenating the retrieved values.
-
Re: sql query help...
Suresh,
As Innila said i would suggest you to use cursors in pl/sql procedure in order to get this done.
There is an another thread under ORACLE. There so many work arounds have been discussed for such a similar requirement. That might give you some idea....
[url]http://www.geekinterview.com/talk/4924-what-sql-statement-can-i-use.html[/url]
-
Re: sql query help...
Thanks to all of you for a quick reply....
-
Re: sql query help...
what is the query? you have not mentioned anything.
-
Re: sql query help...
dear
vunnavahh
please go through the previous posts before posting anything .