Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2016
    Posts
    1

    Exclamation Unanswered: Help!! db2 query - URGENT

    Hi All,
    I am tester and do not have much expertise on db2. I am struggling to get data off a table and want it in a particular order. I would be grateful if anyone can help me.. The table has three columns - id, name and value
    For e.g.
    ID NAME VALUE
    2 Number of fruits 3
    2 fruit 1 apple
    2 fruit 3 orange
    2 fruit 2 kiwi
    1 List of items displayed
    3 Number of fruits 4
    3 vegie 2 cabbage
    3 vegie 4 carrot
    3 vegie 1 beans
    3 vegie 3 potato

    I want the extract to look like -

    1 List of items displayed
    2 Number of fruits 3
    2 fruit 1 apple
    2 fruit 2 kiwi
    2 fruit 3 orange
    3 Number of fruits 4
    3 vegie 1 beans
    3 vegie 2 cabbage
    3 vegie 3 potato
    3 vegie 4 carrot

    Your help will be much appreciated!! Thanks in advance..

  2. #2
    Join Date
    Oct 2007
    Posts
    152
    Provided Answers: 9
    select * from table
    order by 1, case when name like 'Number%' then 1 else 2 end, 3

Posting Permissions

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