Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2002
    Posts
    6

    Unanswered: Converting Oracle encode function to T-SQL syntax

    I am looking for the correct syntax to convert Oracle encode function into T-SQl syntax. Please provide specific syntax and examples.

    Thank you.

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    CASE will do the job

    example (from the doc above):
    Code:
    SELECT 'Price Category' = 
          CASE 
             WHEN price IS NULL THEN 'Not yet priced'
             WHEN price < 10 THEN 'Very Reasonable Title'
             WHEN price >= 10 and price < 20 
                   THEN 'Coffee Table Title'
             ELSE 'Expensive book!'
          END,
       CAST(title AS varchar(20)) AS 'Shortened Title'
    FROM titles
    ORDER BY price
    rudy
    http://rudy.ca/

Posting Permissions

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