Results 1 to 5 of 5

Thread: Query

  1. #1
    Junior Member
    Join Date
    Apr 2007
    Answers
    2

    Question Query

    Hi everyone, I'm making a query to one table and I need to get different information from one numeric field but there is not data in all records... how can I get a zero in the result??????


  2. #2
    Expert Member
    Join Date
    Dec 2006
    Answers
    204

    Re: Query

    use decode then.


  3. #3
    Contributing Member
    Join Date
    Mar 2007
    Answers
    42

    Re: Query

    Decode function has the functionality of an IF-THEN-ELSE statement.

    The syntax for the decode function is:

    decode( expression , search , result [, search , result]... [, default] )

    expression is the value to compare.

    search is the value that is compared against expression.

    result is the value returned, if expression is equal to search.

    default is optional. If no matches are found, the decode will return default. If default is omitted, then the decode statement will return null (if no matches are found).

    For Example:

    You could use the decode function in an SQL statement as follows:

    SELECT supplier_name,
    decode(supplier_id, 10000, 'DELL',
    10001, 'INFOSYS',
    10002, 'WIPRO',
    'Gateway') result
    FROM suppliers;


  4. #4
    Junior Member
    Join Date
    Apr 2007
    Answers
    2

    Talking Re: Query

    Thanks a lot Barbie and varmakub; the query is showing the correct information right now.


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

    Re: Query

    simply use decode as suggested.


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