Next row value

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • iceman23
    New Member
    • Aug 2009
    • 12

    Next row value

    Hello,

    Here is my question to you guys.

    Having a list of items for example:

    Table Fruits
    Name Description
    Apple sweet
    Orange round
    Mango ripe

    I queried:
    select *
    from Fruits
    where description like 'sweet'

    My result is:

    Name Description
    Apple sweet


    My problem scenario is I would like to add another column from the result above and I would like to name that column Fruit2 and I would like to have the value of column Fruit2 the next row value which is orange..

    The way I would want the result would be like this:

    Name Description Fruit2
    Apple sweet orange



    Thanks in advance.
  • code green
    Recognized Expert Top Contributor
    • Mar 2007
    • 1726

    #2
    I would like to have the value of column Fruit2 the next row value
    "Next row" is a meaningless concept in databases.
    If this is really what you want to do then you will need an extra column in your table called 'row_number'

    You need to think outside the flat file design and decide what it is you are trying to achieve.
    Yes, it is possible to get 'The next row' but the DB engine will decide what is the next row.
    Nothing to do with the table entries.

    Comment

    Working...