Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2004
    Posts
    13

    Unanswered: convert to T-SQL

    can anybody convert this to T-SQl :

    Select decode(trunc((d_vst_btcdte - nvl(n_per_birth,d_vst_btcdte))/10000,0),0,'no DOB',
    14,'14-16',15,'14-16',16,'14-16',
    17,'17-20',18,'17-20',19,'17-20',20,'17-20',
    21,'21-25',22,'21-25',23,'21-25',24,'21-25',25,'21-25',
    26,'26-30',27,'26-30',28,'26-30',29,'26-30',30,'26-30',
    31,'31-35',32,'31-35',33,'31-35',34,'31-35',35,'31-35',
    36,'36-40',37,'36-40',38,'36-40',39,'36-40',40,'36-40',
    41,'41-45',42,'41-45',43,'41-45',44,'41-45',45,'41-45',
    46,'46-50',47,'46-50',48,'46-50',49,'46-50',50,'46-50',
    51,'51-55',52,'51-55',53,'51-55',54,'51-55',55,'51-55',
    56,'56-60',57,'56-60',58,'56-60',59,'56-60',60,'56-60',
    61,'61-65',62,'61-65',63,'61-65',64,'61-65',65,'61-65',
    66,'66-70',67,'66-70',68,'66-70',69,'66-70',70,'66-70',
    '71+') AGE

  2. #2
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Yes...

    Code:
    DECLARE @x decimal(15,4)
    SELECT @x = 21.0125
    
    SELECT CASE 
      WHEN ISNULL(FLOOR(@x),0) = 0			THEN 'NO DOB'
      WHEN ISNULL(FLOOR(@x),0) IN (14, 15, 16)	THEN '14-16'
      WHEN ISNULL(FLOOR(@x),0) IN (17, 18, 19, 20)  THEN '17-20'
      WHEN ISNULL(FLOOR(@x),0) IN (21, 22, 23, 24)  THEN '21-24'
    --etc
      ELSE '71+'
    END AS AGE
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

Posting Permissions

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