Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2011
    Posts
    28

    Unanswered: Select Query in DB2

    Hi All,

    I have to create a query which will return result from a table. I need to show all the records but top row will must show what user has searched in the table.

    I tried a query but it is returning only 1 row that is the one user has searched and if I try to use this query with order by, it is not working.

    Kindly suggest if someone is having any idea on this.


    Thanks in advance.

  2. #2
    Join Date
    Feb 2008
    Location
    Japan
    Posts
    3,483
    If "what user has searched in the table" was same as the result of this query,
    Code:
    SELECT ...
     FROM  <the table>
     WHERE <some conditions>
    your required query may look like...
    Code:
    SELECT ...
     FROM  <the table>
     ORDER BY
           CASE
           WHEN <some conditions> THEN
                0
           ELSE 1
           END

  3. #3
    Join Date
    Apr 2011
    Posts
    28
    Hi,


    It is done using UNION keyword. Using UNION, I used two select queries to get required results.


    Thanks.

Tags for this Thread

Posting Permissions

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