Results 1 to 7 of 7

Thread: sql query help...

  1. #1
    Contributing Member
    Join Date
    Sep 2006
    Answers
    962

    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...

    select Benefits from MemberDetails where MembershipID=10; 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?


  2. #2
    Contributing Member
    Join Date
    Apr 2006
    Answers
    46

    Re: sql query help...

    hi
    give your table with data and one sample req. o/p


  3. #3
    Expert Member
    Join Date
    Sep 2006
    Answers
    130

    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.

    Last edited by Innila; 07-12-2007 at 06:31 AM.
    *** Innila ***

  4. #4
    Expert Member
    Join Date
    Jun 2006
    Answers
    410

    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....
    http://www.geekinterview.com/talk/49...can-i-use.html


  5. #5
    Contributing Member
    Join Date
    Sep 2006
    Answers
    962

    Re: sql query help...

    Thanks to all of you for a quick reply....


  6. #6
    Junior Member
    Join Date
    Jun 2006
    Answers
    1

    Re: sql query help...

    what is the query? you have not mentioned anything.


  7. #7
    Moderator
    Join Date
    Jun 2007
    Answers
    2,074

    Re: sql query help...

    dear
    vunnavahh

    please go through the previous posts before posting anything .


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact