Results 1 to 5 of 5

Thread: multiple column query - probably simple for one who knows!

  1. #1
    Join Date
    Jun 2003
    Posts
    2

    Lightbulb multiple column query - probably simple for one who knows!

    Simple question:

    I am handling an oracle sql database and one of my table combines multiple fields (defined as field_name, field_value) from workflows which are defined in another table.

    So something similar like this:

    (workflow, field_name, field_value):
    (1, field1, 'Monday')
    (1, field2, 'Tuesday')
    (1, field3, 'Wednesday')

    what kind of sql query do I have to use that a similar to the following occures:

    1, 'Monday', 'Tuesday'

    Sorry to bother you, but I (as an SQL beginner) would very much appreciate your comment.

  2. #2
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,932
    Try this

    select workflow,
    max(decode(field_name,'field1',field_value,''),
    max(decode(field_name,'field2',field_value,''),
    max(decode(field_name,'field3',field_value,'')
    from yourtable
    group by workflow

  3. #3
    Join Date
    Jun 2003
    Posts
    2

    Smile

    Shailesh Khanal,

    thanks a lot, it worked!

    Can you recommend an internet page where this sort of code is described in detail ?? All book/page available to me, handling only basic stuff. So, any recommendation?

    Thanks a lot in advance.

    Tim.

  4. #4
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,932
    If you have access to metalink.oracle.com, it is a good source.

    Otherwise you can go to
    technet.oracle.com
    lazydba.com
    dbazine.com

  5. #5
    Join Date
    Mar 2003
    Posts
    468
    all oracle documentation can be found at
    http://tahiti.oracle.com/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •