Home Forums SQL Server 2008 T-SQL (SS2K8) Urgent Query help needed- calculate one field based on other field in SELECT statment RE: Urgent Query help needed- calculate one field based on other field in SELECT statment

  • Is type casting required?. I think it is not required. Even though it is a varchar type, SQL Engine will convert it internally in this scenario. Please correct me, if I wrong.

    The below code will work:

    CASE

    WHEN [Age (Working Days)] < 30

    THEN '1 - 29'

    WHEN [Age (Working Days)] < 60

    THEN '30 - 59'

    WHEN [Age (Working Days)] < 90

    THEN '60 - 89'

    WHEN [Age (Working Days)] < 120

    THEN '90 - 119'

    ELSE'120 +'